# Path: aodh/api/controllers/v2/query.py
# LOG = log.getLogger(__name__)
# class ComplexQuery(base.Base):
# class ValidatedComplexQuery(object):
# class QueryAlarmHistoryController(rest.RestController):
# class QueryAlarmsController(rest.RestController):
# class QueryController(rest.RestController):
#     def sample(cls):
# def _list_to_regexp(items, regexp_prefix=""):
#     def __init__(self, query, db_model, additional_name_mapping=None,
#                  metadata_allowed=False):
#     def validate(self, visibility_field):
#     def lowercase_values(mapping):
#     def _convert_orderby_to_lower_case(self, orderby):
#     def _normalize_field_names_in_orderby(self, orderby):
#     def _traverse_postorder(self, tree, visitor):
#     def _check_cross_project_references(self, own_project_id,
#                                         visibility_field):
#         def check_project_id(subfilter):
#     def _force_visibility(self, visibility_field):
#     def _restrict_to_project(self, project_id, visibility_field):
#     def _replace_isotime_with_datetime(self, filter_expr):
#         def replace_isotime(subfilter):
#     def _normalize_field_names_for_db_model(self, filter_expr):
#         def _normalize_field_names(subfilter):
#     def _replace_field_names(self, subfilter):
#     def lowercase_keys(mapping):
#     def _convert_operator_to_lower_case(self, filter_expr):
#     def _convert_to_datetime(isotime):
#     def _validate_filter(self, filter_expr):
#     def _validate_orderby(self, orderby_expr):
#     def post(self, body):
#     def post(self, body):
# 
# Path: aodh/storage/models.py
# class Alarm(base.Model):
# class AlarmChange(base.Model):
# class Quota(base.Model):
#     ALARM_INSUFFICIENT_DATA = 'insufficient data'
#     ALARM_OK = 'ok'
#     ALARM_ALARM = 'alarm'
#     ALARM_ACTIONS_MAP = {
#         ALARM_INSUFFICIENT_DATA: 'insufficient_data_actions',
#         ALARM_OK: 'ok_actions',
#         ALARM_ALARM: 'alarm_actions',
#     }
#     ALARM_LEVEL_LOW = 'low'
#     ALARM_LEVEL_MODERATE = 'moderate'
#     ALARM_LEVEL_CRITICAL = 'critical'
#     SUPPORT_SORT_KEYS = (
#         'alarm_id', 'enabled', 'name', 'type', 'severity', 'timestamp',
#         'user_id', 'project_id', 'state', 'repeat_actions', 'state_timestamp')
#     DEFAULT_SORT = [('timestamp', 'desc')]
#     PRIMARY_KEY = 'alarm_id'
#     CREATION = 'creation'
#     RULE_CHANGE = 'rule change'
#     STATE_TRANSITION = 'state transition'
#     DELETION = 'deletion'
#     SUPPORT_SORT_KEYS = (
#         'event_id', 'alarm_id', 'on_behalf_of', 'project_id', 'user_id',
#         'type', 'timestamp', 'severity')
#     DEFAULT_SORT = [('timestamp', 'desc')]
#     PRIMARY_KEY = 'event_id'
#     def __init__(self, alarm_id, type, enabled, name, description,
#                  timestamp, user_id, project_id, state, state_timestamp,
#                  state_reason, ok_actions, alarm_actions,
#                  insufficient_data_actions, repeat_actions, rule,
#                  time_constraints, severity=None, evaluate_timestamp=None):
#     def __init__(self,
#                  event_id,
#                  alarm_id,
#                  type,
#                  detail,
#                  user_id,
#                  project_id,
#                  on_behalf_of,
#                  severity=None,
#                  timestamp=None
#                  ):
#     def __init__(self, project_id, resource, limit):


import datetime
import fixtures
import jsonschema
import wsme
from unittest import mock
from oslotest import base
from aodh.api.controllers.v2 import query
from aodh.storage import models as alarm_models
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.
"""Test the methods related to complex query."""




class FakeComplexQuery(query.ValidatedComplexQuery):
    def __init__(self, db_model, additional_name_mapping=None, metadata=False):
        super(FakeComplexQuery, self).__init__(query=None,
                                               db_model=db_model,
                                               additional_name_mapping=(
                                                   additional_name_mapping or
                                                   {}),
                                               metadata_allowed=metadata)


class TestComplexQuery(base.BaseTestCase):
    def setUp(self):
        super(TestComplexQuery, self).setUp()
        self.useFixture(fixtures.MonkeyPatch(
            'pecan.response', mock.MagicMock()))

# Path: aodh/api/controllers/v2/query.py
# LOG = log.getLogger(__name__)
# class ComplexQuery(base.Base):
# class ValidatedComplexQuery(object):
# class QueryAlarmHistoryController(rest.RestController):
# class QueryAlarmsController(rest.RestController):
# class QueryController(rest.RestController):
#     def sample(cls):
# def _list_to_regexp(items, regexp_prefix=""):
#     def __init__(self, query, db_model, additional_name_mapping=None,
#                  metadata_allowed=False):
#     def validate(self, visibility_field):
#     def lowercase_values(mapping):
#     def _convert_orderby_to_lower_case(self, orderby):
#     def _normalize_field_names_in_orderby(self, orderby):
#     def _traverse_postorder(self, tree, visitor):
#     def _check_cross_project_references(self, own_project_id,
#                                         visibility_field):
#         def check_project_id(subfilter):
#     def _force_visibility(self, visibility_field):
#     def _restrict_to_project(self, project_id, visibility_field):
#     def _replace_isotime_with_datetime(self, filter_expr):
#         def replace_isotime(subfilter):
#     def _normalize_field_names_for_db_model(self, filter_expr):
#         def _normalize_field_names(subfilter):
#     def _replace_field_names(self, subfilter):
#     def lowercase_keys(mapping):
#     def _convert_operator_to_lower_case(self, filter_expr):
#     def _convert_to_datetime(isotime):
#     def _validate_filter(self, filter_expr):
#     def _validate_orderby(self, orderby_expr):
#     def post(self, body):
#     def post(self, body):
# 
# Path: aodh/storage/models.py
# class Alarm(base.Model):
# class AlarmChange(base.Model):
# class Quota(base.Model):
#     ALARM_INSUFFICIENT_DATA = 'insufficient data'
#     ALARM_OK = 'ok'
#     ALARM_ALARM = 'alarm'
#     ALARM_ACTIONS_MAP = {
#         ALARM_INSUFFICIENT_DATA: 'insufficient_data_actions',
#         ALARM_OK: 'ok_actions',
#         ALARM_ALARM: 'alarm_actions',
#     }
#     ALARM_LEVEL_LOW = 'low'
#     ALARM_LEVEL_MODERATE = 'moderate'
#     ALARM_LEVEL_CRITICAL = 'critical'
#     SUPPORT_SORT_KEYS = (
#         'alarm_id', 'enabled', 'name', 'type', 'severity', 'timestamp',
#         'user_id', 'project_id', 'state', 'repeat_actions', 'state_timestamp')
#     DEFAULT_SORT = [('timestamp', 'desc')]
#     PRIMARY_KEY = 'alarm_id'
#     CREATION = 'creation'
#     RULE_CHANGE = 'rule change'
#     STATE_TRANSITION = 'state transition'
#     DELETION = 'deletion'
#     SUPPORT_SORT_KEYS = (
#         'event_id', 'alarm_id', 'on_behalf_of', 'project_id', 'user_id',
#         'type', 'timestamp', 'severity')
#     DEFAULT_SORT = [('timestamp', 'desc')]
#     PRIMARY_KEY = 'event_id'
#     def __init__(self, alarm_id, type, enabled, name, description,
#                  timestamp, user_id, project_id, state, state_timestamp,
#                  state_reason, ok_actions, alarm_actions,
#                  insufficient_data_actions, repeat_actions, rule,
#                  time_constraints, severity=None, evaluate_timestamp=None):
#     def __init__(self,
#                  event_id,
#                  alarm_id,
#                  type,
#                  detail,
#                  user_id,
#                  project_id,
#                  on_behalf_of,
#                  severity=None,
#                  timestamp=None
#                  ):
#     def __init__(self, project_id, resource, limit):


# Path: aodh/tests/functional/api/v2/test_complex_query.py
import datetime
import fixtures
import jsonschema
import wsme
from unittest import mock
from oslotest import base
from aodh.api.controllers.v2 import query
from aodh.storage import models as alarm_models

#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.
"""Test the methods related to complex query."""




class FakeComplexQuery(query.ValidatedComplexQuery):
    def __init__(self, db_model, additional_name_mapping=None, metadata=False):
        super(FakeComplexQuery, self).__init__(query=None,
                                               db_model=db_model,
                                               additional_name_mapping=(
                                                   additional_name_mapping or
                                                   {}),
                                               metadata_allowed=metadata)


class TestComplexQuery(base.BaseTestCase):
    def setUp(self):
        super(TestComplexQuery, self).setUp()
        self.useFixture(fixtures.MonkeyPatch(
            'pecan.response', mock.MagicMock()))

        self.query = FakeComplexQuery(alarm_models.Alarm)