# Path: seedbox/db/sqlalchemy/models.py
# NONE_TYPE = 'none'
# BOOL_TYPE = 'bool'
# DATE_TYPE = 'datetime'
# INT_TYPE = 'int'
# STR_TYPE = 'str'
# VAL_TYPES = [NONE_TYPE, BOOL_TYPE, DATE_TYPE, INT_TYPE, STR_TYPE]
# def to_table_name(klass_name):
#     def __tablename__(cls):
#     def save(self, session):
#     def __repr__(self):
#     def __setitem__(self, key, value):
#     def __getitem__(self, key):
#     def get(self, key, default=None):
#     def __iter__(self):
#     def __next__(self):
#     def next(self):
#     def update(self, values):
#     def iteritems(self):
#     def __init__(self, id, value=None):
#     def __setitem__(self, key, value):
#     def __getitem__(self, key):
#     def get(self, key, default=None):
#     def update(self, values):
#     def get_value(self):
#     def set_value(self, value):
#     def reset_value(self):
#     def __repr__(self):
# def verify_tables(engine):
# def purge_all_tables(engine):
#     def __init__(self, table, query):
#     def _handle_complex_op(self, complex_op, nodes):
#     def _handle_simple_op(self, simple_op, nodes):
#     def _transform(self, sub_tree):
#     def apply_filter(self, expression_tree):
# class Base(six.Iterator):
# class HasId(object):
# class HasTimestamp(object):
# class Torrent(Base, HasId, HasTimestamp):
# class MediaFile(Base, HasId):
# class AppState(Base):
# class QueryTransformer(object):
# 
# Path: seedbox/db/sqlalchemy/session.py
# @property
# def session(self):
#     """Get a Session instance."""
#     return self._session_maker()
# 
# Path: seedbox/tests/test.py
# class ConfiguredBaseTestCase(BaseTestCase):
#     def setUp(self):
#     def tearDown(self):
#     def _make_dir(self, dirname):
#     def set_required_options(self):


from datetime import datetime
from seedbox.db.sqlalchemy import models
from seedbox.db.sqlalchemy import session
from seedbox.tests import test
import sqlalchemy as sa
import testtools
        altstr1_state = models.AppState('str_state', None)
        self.assertEqual(altstr1_state.get_value(), None)

        models.AppState('str_state', u'ustring')

        int_state = models.AppState('int_state', 7)
        self.assertEqual(int_state.get_value(), 7)

        bool_state = models.AppState('bool_state', True)
        self.assertEqual(bool_state.get_value(), True)

        values = {'value': False}
        bool_state.update(values)
        self.assertEqual(bool_state.get_value(), False)

        _date = datetime.utcnow()
        date_state = models.AppState('date_state', _date)
        self.assertEqual(date_state.get_value(), _date)

        models.AppState('date_state', datetime.utcnow().date())

        with testtools.ExpectedException(TypeError):
            str_state.set_value(object())

        with testtools.ExpectedException(TypeError):
            models.AppState('str_state', object())

    def test_query_transform(self):

        transformer = models.QueryTransformer(

# Path: seedbox/db/sqlalchemy/models.py
# NONE_TYPE = 'none'
# BOOL_TYPE = 'bool'
# DATE_TYPE = 'datetime'
# INT_TYPE = 'int'
# STR_TYPE = 'str'
# VAL_TYPES = [NONE_TYPE, BOOL_TYPE, DATE_TYPE, INT_TYPE, STR_TYPE]
# def to_table_name(klass_name):
#     def __tablename__(cls):
#     def save(self, session):
#     def __repr__(self):
#     def __setitem__(self, key, value):
#     def __getitem__(self, key):
#     def get(self, key, default=None):
#     def __iter__(self):
#     def __next__(self):
#     def next(self):
#     def update(self, values):
#     def iteritems(self):
#     def __init__(self, id, value=None):
#     def __setitem__(self, key, value):
#     def __getitem__(self, key):
#     def get(self, key, default=None):
#     def update(self, values):
#     def get_value(self):
#     def set_value(self, value):
#     def reset_value(self):
#     def __repr__(self):
# def verify_tables(engine):
# def purge_all_tables(engine):
#     def __init__(self, table, query):
#     def _handle_complex_op(self, complex_op, nodes):
#     def _handle_simple_op(self, simple_op, nodes):
#     def _transform(self, sub_tree):
#     def apply_filter(self, expression_tree):
# class Base(six.Iterator):
# class HasId(object):
# class HasTimestamp(object):
# class Torrent(Base, HasId, HasTimestamp):
# class MediaFile(Base, HasId):
# class AppState(Base):
# class QueryTransformer(object):
# 
# Path: seedbox/db/sqlalchemy/session.py
# @property
# def session(self):
#     """Get a Session instance."""
#     return self._session_maker()
# 
# Path: seedbox/tests/test.py
# class ConfiguredBaseTestCase(BaseTestCase):
#     def setUp(self):
#     def tearDown(self):
#     def _make_dir(self, dirname):
#     def set_required_options(self):


# Path: seedbox/tests/db/sqlalchemy/test_models.py
from datetime import datetime
from seedbox.db.sqlalchemy import models
from seedbox.db.sqlalchemy import session
from seedbox.tests import test
import sqlalchemy as sa
import testtools

        altstr1_state = models.AppState('str_state', None)
        self.assertEqual(altstr1_state.get_value(), None)

        models.AppState('str_state', u'ustring')

        int_state = models.AppState('int_state', 7)
        self.assertEqual(int_state.get_value(), 7)

        bool_state = models.AppState('bool_state', True)
        self.assertEqual(bool_state.get_value(), True)

        values = {'value': False}
        bool_state.update(values)
        self.assertEqual(bool_state.get_value(), False)

        _date = datetime.utcnow()
        date_state = models.AppState('date_state', _date)
        self.assertEqual(date_state.get_value(), _date)

        models.AppState('date_state', datetime.utcnow().date())

        with testtools.ExpectedException(TypeError):
            str_state.set_value(object())

        with testtools.ExpectedException(TypeError):
            models.AppState('str_state', object())

    def test_query_transform(self):

        transformer = models.QueryTransformer(

            models.Torrent, self.facade.session.query(models.Torrent))