# 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
# 
# 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
from falconswagger.models.orm.session import Session
from falconswagger.exceptions import ModelBaseError
from unittest import mock
import pytest
import msgpack
import sqlalchemy as sa
                'id': 1,
                '_operation': 'update',
                'model2': [{
                    'id': 1,
                    '_operation': 'remove'
                }]
            }
        }
        objs = model3.insert(session, m3_insert)
        assert session.query(model2_mto).one().todict() == {'id': 1, 'model1_id': None}

        expected = {
            'id': 1,
            'model1_id': 1,
            'model2_id': None,
            'model1': {
                'id': 1,
                'model2': []
            },
            'model2': None
        }
        assert objs == [expected]

    def test_insert_nested_update_without_relationships(
            self, model1, model2, session, redis):
        with pytest.raises(ModelBaseError):
            model2.insert(session, {'model1': {'id': 1, '_operation': 'update'}})

    def test_insert_nested_remove_without_relationships(
            self, model1, model2, session, redis):

# 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
# 
# 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/integration/base/models/test_sqlalchemy_redis_integration.py
from falconswagger.models.orm.sqlalchemy_redis import ModelSQLAlchemyRedisFactory
from falconswagger.models.orm.session import Session
from falconswagger.exceptions import ModelBaseError
from unittest import mock
import pytest
import msgpack
import sqlalchemy as sa

                'id': 1,
                '_operation': 'update',
                'model2': [{
                    'id': 1,
                    '_operation': 'remove'
                }]
            }
        }
        objs = model3.insert(session, m3_insert)
        assert session.query(model2_mto).one().todict() == {'id': 1, 'model1_id': None}

        expected = {
            'id': 1,
            'model1_id': 1,
            'model2_id': None,
            'model1': {
                'id': 1,
                'model2': []
            },
            'model2': None
        }
        assert objs == [expected]

    def test_insert_nested_update_without_relationships(
            self, model1, model2, session, redis):
        with pytest.raises(ModelBaseError):
            model2.insert(session, {'model1': {'id': 1, '_operation': 'update'}})

    def test_insert_nested_remove_without_relationships(
            self, model1, model2, session, redis):

        with pytest.raises(ModelBaseError):