# Path: falconswagger/models/orm/sqlalchemy_redis.py
# class ModelSQLAlchemyRedisFactory(object):
# 
#     @staticmethod
#     def make(name='ModelSQLAlchemyRedisBase', bind=None, metadata=None,
#              mapper=None, class_registry=None, authorizer=None, keys_separator=b'|'):
#         base = declarative_base(
#             name=name, metaclass=ModelSQLAlchemyRedisMeta,
#             cls=_ModelSQLAlchemyRedisBase, bind=bind, metadata=metadata,
#             mapper=mapper, constructor=_ModelSQLAlchemyRedisBase.__init__)
#         base.__authorizer__ = authorizer
#         base.__keys_separator__ = \
#             keys_separator.decode() if isinstance(keys_separator, str) else keys_separator
#         return base
# 
# class ModelSQLAlchemyRedisMeta(
#         ModelSQLAlchemyRedisInitMetaMixin,
#         ModelSQLAlchemyRedisOperationsMetaMixin):
#     pass
# 
# Path: falconswagger/models/orm/session.py
# class _SessionBase(SessionSA):
#     def __init__(
#             self, bind=None, autoflush=True,
#             expire_on_commit=True, _enable_transaction_accounting=True,
#             autocommit=False, twophase=False, weak_identity_map=True,
#             binds=None, extension=None, info=None, query_cls=Query, redis_bind=None):
#     def _clean_redis_sets(self):
#     def commit(self):
#     def delete(self, instance):
#     def _update_objects_on_redis(self):
#     def _exec_hdel(self, insts):
#     def _get_filters_names_set(self, inst):
#     def _exec_hmset(self, insts):
#     def mark_for_hdel(self, inst):
#     def mark_for_hmset(self, inst):
# def deleted_from_database(session, instance):
# def added_to_database(session, instance):
# 
# Path: falconswagger/exceptions.py
# class ModelBaseError(FalconSwaggerError):
#     def __init__(self, message, input_=None):
#         FalconSwaggerError.__init__(self, message, HTTP_BAD_REQUEST)
#         self.input_ = input_


from falconswagger.models.orm.sqlalchemy_redis import ModelSQLAlchemyRedisFactory, ModelSQLAlchemyRedisMeta
from falconswagger.models.orm.session import Session
from falconswagger.exceptions import ModelBaseError
from unittest import mock
import pytest
import sqlalchemy as sa

    def test_if_builds_relationships_correctly_with_one_model_set_with_string(
            self, model1, model2_string):
        assert model2_string.__relationships__ == {'model1': model2_string.model1}

    def test_if_builds_relationships_correctly_with_two_models_set_with_string(
            self, model1, model2, model3_string):
        assert model3_string.__relationships__ == {
            'model1': model3_string.model1, 'model2': model3_string.model2}

    def test_if_builds_backrefs_correctly_with_one_model(self, model2, model3):
        assert model2.__backrefs__ == {model3.model2}

    def test_if_builds_backrefs_correctly_with_two_models(self, model1, model2, model3):
        assert model1.__backrefs__ == {model2.model1, model3.model1}

    def test_if_builds_primaries_keys_correctly(self, model_base):
        class model(model_base):
                __tablename__ = 'test'
                id3 = sa.Column(sa.Integer, primary_key=True)
                id1 = sa.Column(sa.Integer, primary_key=True)
                id2 = sa.Column(sa.Integer, primary_key=True)

        assert model.primaries_keys == {'id1': model.id1, 'id2': model.id2, 'id3': model.id3}

    def test_raises_model_error_with_invalid_base_class(self):
        class model(object):
            __baseclass_name__ = 'Test'
            id = sa.Column(sa.Integer, primary_key=True)


# Path: falconswagger/models/orm/sqlalchemy_redis.py
# class ModelSQLAlchemyRedisFactory(object):
# 
#     @staticmethod
#     def make(name='ModelSQLAlchemyRedisBase', bind=None, metadata=None,
#              mapper=None, class_registry=None, authorizer=None, keys_separator=b'|'):
#         base = declarative_base(
#             name=name, metaclass=ModelSQLAlchemyRedisMeta,
#             cls=_ModelSQLAlchemyRedisBase, bind=bind, metadata=metadata,
#             mapper=mapper, constructor=_ModelSQLAlchemyRedisBase.__init__)
#         base.__authorizer__ = authorizer
#         base.__keys_separator__ = \
#             keys_separator.decode() if isinstance(keys_separator, str) else keys_separator
#         return base
# 
# class ModelSQLAlchemyRedisMeta(
#         ModelSQLAlchemyRedisInitMetaMixin,
#         ModelSQLAlchemyRedisOperationsMetaMixin):
#     pass
# 
# Path: falconswagger/models/orm/session.py
# class _SessionBase(SessionSA):
#     def __init__(
#             self, bind=None, autoflush=True,
#             expire_on_commit=True, _enable_transaction_accounting=True,
#             autocommit=False, twophase=False, weak_identity_map=True,
#             binds=None, extension=None, info=None, query_cls=Query, redis_bind=None):
#     def _clean_redis_sets(self):
#     def commit(self):
#     def delete(self, instance):
#     def _update_objects_on_redis(self):
#     def _exec_hdel(self, insts):
#     def _get_filters_names_set(self, inst):
#     def _exec_hmset(self, insts):
#     def mark_for_hdel(self, inst):
#     def mark_for_hmset(self, inst):
# def deleted_from_database(session, instance):
# def added_to_database(session, instance):
# 
# Path: falconswagger/exceptions.py
# class ModelBaseError(FalconSwaggerError):
#     def __init__(self, message, input_=None):
#         FalconSwaggerError.__init__(self, message, HTTP_BAD_REQUEST)
#         self.input_ = input_


# Path: tests/unit/base/models/test_sqlalchemy_redis.py
from falconswagger.models.orm.sqlalchemy_redis import ModelSQLAlchemyRedisFactory, ModelSQLAlchemyRedisMeta
from falconswagger.models.orm.session import Session
from falconswagger.exceptions import ModelBaseError
from unittest import mock
import pytest
import sqlalchemy as sa


    def test_if_builds_relationships_correctly_with_one_model_set_with_string(
            self, model1, model2_string):
        assert model2_string.__relationships__ == {'model1': model2_string.model1}

    def test_if_builds_relationships_correctly_with_two_models_set_with_string(
            self, model1, model2, model3_string):
        assert model3_string.__relationships__ == {
            'model1': model3_string.model1, 'model2': model3_string.model2}

    def test_if_builds_backrefs_correctly_with_one_model(self, model2, model3):
        assert model2.__backrefs__ == {model3.model2}

    def test_if_builds_backrefs_correctly_with_two_models(self, model1, model2, model3):
        assert model1.__backrefs__ == {model2.model1, model3.model1}

    def test_if_builds_primaries_keys_correctly(self, model_base):
        class model(model_base):
                __tablename__ = 'test'
                id3 = sa.Column(sa.Integer, primary_key=True)
                id1 = sa.Column(sa.Integer, primary_key=True)
                id2 = sa.Column(sa.Integer, primary_key=True)

        assert model.primaries_keys == {'id1': model.id1, 'id2': model.id2, 'id3': model.id3}

    def test_raises_model_error_with_invalid_base_class(self):
        class model(object):
            __baseclass_name__ = 'Test'
            id = sa.Column(sa.Integer, primary_key=True)


        with pytest.raises(ModelBaseError) as error: