# Path: monasca_api/common/repositories/sqla/models.py
# def get_all_metadata():
# def create_a_model(metadata=None):
# def create_sadd_model(metadata=None):
# def create_aa_model(metadata=None):
# def create_md_model(metadata=None):
# def create_mde_model(metadata=None):
# def create_nm_model(metadata=None):
# def create_nmt_model(metadata=None):
# def create_mdd_model(metadata=None):
# def create_am_model(metadata=None):
# def create_ad_model(metadata=None):
# def create_sa_model(metadata=None):
# def create_sad_model(metadata=None):
#     def __init__(self, columns, separator=',', order_by=None):
# def _group_concat_oracle(element, compiler_, **kw):
# def _group_concat_postgresql(element, compiler_, **kw):
# def _group_concat_sybase(element, compiler_, **kw):
# def _group_concat_mysql(element, compiler_, **kw):
# def _group_concat_default(element, compiler_, **kw):
#     def __init__(self, column, fields):
# def _field_sort_mysql(element, compiler_, **kw):
# def _field_sort_general(element, compiler_, **kw):
# class group_concat(expression.ColumnElement):
# class field_sort(expression.ColumnElement):


import datetime
import fixtures
        import copy
        import copy
from oslo_config import cfg
from oslo_config import fixture as fixture_config
from oslo_db.sqlalchemy.engines import create_engine
from sqlalchemy import delete, MetaData, insert, bindparam
from monasca_api.common.repositories.sqla import models
from monasca_api.tests import base
        from monasca_api.common.repositories.sqla import notifications_repository as nr
                from sqlalchemy import create_engine
        from monasca_api.common.repositories import exceptions
        from monasca_api.common.repositories import exceptions
        from monasca_api.common.repositories import exceptions
        from monasca_api.common.repositories import exceptions
        self.assertEqual(expected, nms)

    def test_should_find(self):
        nms = self.repo.list_notifications('444', None, None, 2)
        self.assertEqual(nms, self.default_nms)
        nms = self.repo.list_notifications('444', None, 3, 1)
        self.assertEqual(nms, [])

    def test_should_find_and_sort(self):
        nms = self.repo.list_notifications('444', ['id'], None, 3)
        self.assertEqual(self.default_nms, nms)

        nms = self.repo.list_notifications('444', ['name'], None, 3)
        expected = sorted(self.default_nms, key=lambda k: k['name'])
        self.assertEqual(expected, nms)

    def test_update(self):
        self.repo.update_notification('123', '444', 'Foo', 'EMAIL', 'abc', 0)
        nm = self.repo.list_notification('444', '123')
        new_nm = copy.deepcopy(self.default_nms[0])
        new_nm['name'] = b'Foo'
        new_nm['type'] = b'EMAIL'
        new_nm['address'] = b'abc'
        new_nm['created_at'] = nm['created_at']
        new_nm['updated_at'] = nm['updated_at']
        self.assertEqual(nm, new_nm)
        self.assertRaises(exceptions.DoesNotExistException,
                          self.repo.update_notification,
                          'no really id',
                          'no really tenant',

# Path: monasca_api/common/repositories/sqla/models.py
# def get_all_metadata():
# def create_a_model(metadata=None):
# def create_sadd_model(metadata=None):
# def create_aa_model(metadata=None):
# def create_md_model(metadata=None):
# def create_mde_model(metadata=None):
# def create_nm_model(metadata=None):
# def create_nmt_model(metadata=None):
# def create_mdd_model(metadata=None):
# def create_am_model(metadata=None):
# def create_ad_model(metadata=None):
# def create_sa_model(metadata=None):
# def create_sad_model(metadata=None):
#     def __init__(self, columns, separator=',', order_by=None):
# def _group_concat_oracle(element, compiler_, **kw):
# def _group_concat_postgresql(element, compiler_, **kw):
# def _group_concat_sybase(element, compiler_, **kw):
# def _group_concat_mysql(element, compiler_, **kw):
# def _group_concat_default(element, compiler_, **kw):
#     def __init__(self, column, fields):
# def _field_sort_mysql(element, compiler_, **kw):
# def _field_sort_general(element, compiler_, **kw):
# class group_concat(expression.ColumnElement):
# class field_sort(expression.ColumnElement):


# Path: monasca_api/tests/test_nm_repository.py
import datetime
import fixtures
        import copy
        import copy
from oslo_config import cfg
from oslo_config import fixture as fixture_config
from oslo_db.sqlalchemy.engines import create_engine
from sqlalchemy import delete, MetaData, insert, bindparam
from monasca_api.common.repositories.sqla import models
from monasca_api.tests import base
        from monasca_api.common.repositories.sqla import notifications_repository as nr
                from sqlalchemy import create_engine
        from monasca_api.common.repositories import exceptions
        from monasca_api.common.repositories import exceptions
        from monasca_api.common.repositories import exceptions
        from monasca_api.common.repositories import exceptions

        self.assertEqual(expected, nms)

    def test_should_find(self):
        nms = self.repo.list_notifications('444', None, None, 2)
        self.assertEqual(nms, self.default_nms)
        nms = self.repo.list_notifications('444', None, 3, 1)
        self.assertEqual(nms, [])

    def test_should_find_and_sort(self):
        nms = self.repo.list_notifications('444', ['id'], None, 3)
        self.assertEqual(self.default_nms, nms)

        nms = self.repo.list_notifications('444', ['name'], None, 3)
        expected = sorted(self.default_nms, key=lambda k: k['name'])
        self.assertEqual(expected, nms)

    def test_update(self):
        self.repo.update_notification('123', '444', 'Foo', 'EMAIL', 'abc', 0)
        nm = self.repo.list_notification('444', '123')
        new_nm = copy.deepcopy(self.default_nms[0])
        new_nm['name'] = b'Foo'
        new_nm['type'] = b'EMAIL'
        new_nm['address'] = b'abc'
        new_nm['created_at'] = nm['created_at']
        new_nm['updated_at'] = nm['updated_at']
        self.assertEqual(nm, new_nm)
        self.assertRaises(exceptions.DoesNotExistException,
                          self.repo.update_notification,
                          'no really id',
                          'no really tenant',

                          '',