示例#1
0
    def test_table(self):
        from aiorm import orm
        from aiorm.orm.declaration.meta import db

        oldcounter = orm.table._counter

        @orm.table(database='db0', name='table1', collation='fr_FR.UTF8')
        class Table:
            id = orm.PrimaryKey(orm.Integer)
            name = orm.Column(orm.String)
            _password = orm.Column('password', orm.String)

        self.assertEqual(self.category, 'aiorm')
        self.assertEqual(self.wrapped, Table)
        self.assertEqual(orm.table._counter, oldcounter)
        self.callback(None, None, None)
        self.assertEqual(orm.table._counter, oldcounter + 1)
        self.assertEqual(Table, db['db0']['table1'])
        meta = Table.__meta__.copy()
        self.assertEqual(meta,
                         {'alias': 't{}'.format(oldcounter),
                          'collation': 'fr_FR.UTF8',
                          'columns': None,
                          'attributes': None,
                          'pkv': None,
                          'database': 'db0',
                          'foreign_keys': {},
                          'primary_key': {'id': Table.id},
                          'tablename': 'table1'})
        db.pop('db0')  # cleanUp
示例#2
0
    def test_table(self):
        from aiorm import orm
        from aiorm.orm.declaration.meta import db

        oldcounter = orm.table._counter

        @orm.table(database='db0', name='table1', collation='fr_FR.UTF8')
        class Table:
            id = orm.PrimaryKey(orm.Integer)
            name = orm.Column(orm.String)
            _password = orm.Column('password', orm.String)

        self.assertEqual(self.category, 'aiorm')
        self.assertEqual(self.wrapped, Table)
        self.assertEqual(orm.table._counter, oldcounter)
        self.callback(None, None, None)
        self.assertEqual(orm.table._counter, oldcounter + 1)
        self.assertEqual(Table, db['db0']['table1'])
        meta = Table.__meta__.copy()
        self.assertEqual(
            meta, {
                'alias': 't{}'.format(oldcounter),
                'collation': 'fr_FR.UTF8',
                'columns': None,
                'attributes': None,
                'pkv': None,
                'database': 'db0',
                'foreign_keys': {},
                'primary_key': {
                    'id': Table.id
                },
                'tablename': 'table1'
            })
        db.pop('db0')  # cleanUp
示例#3
0
 def test_scan(self):
     from aiorm import orm
     from aiorm.orm.declaration.meta import db
     orm.scan('aiorm.tests.fixtures.sample')
     from aiorm.tests.fixtures import sample
     self.assertEqual(db,
                      {'sample': {'user': sample.User,
                                  'group': sample.Group,
                                  'user_group': sample.UserGroup,
                                  'preference': sample.Preference,
                                  'user_preference': sample.UserPreference,
                                  }})
     db.pop('sample')
示例#4
0
 def test_scan(self):
     from aiorm import orm
     from aiorm.orm.declaration.meta import db
     orm.scan('aiorm.tests.fixtures.sample')
     from aiorm.tests.fixtures import sample
     self.assertEqual(
         db, {
             'sample': {
                 'user': sample.User,
                 'group': sample.Group,
                 'user_group': sample.UserGroup,
                 'preference': sample.Preference,
                 'user_preference': sample.UserPreference,
             }
         })
     db.pop('sample')
示例#5
0
    def test_default(self):
        from aiorm.orm.declaration.meta import db

        self.assertEqual(db,
                         {'sample': {'group': sample.Group,
                                     'preference': sample.Preference,
                                     'user': sample.User,
                                     'user_group': sample.UserGroup,
                                     'user_preference': sample.UserPreference
                                     }})
        self.assertEqual(db['db'], {})
        self.assertEqual(db,
                         {'db': {},
                          'sample': {'group': sample.Group,
                                     'preference': sample.Preference,
                                     'user': sample.User,
                                     'user_group': sample.UserGroup,
                                     'user_preference': sample.UserPreference
                                     }})
        db.pop('db')
示例#6
0
文件: sample.py 项目: zeninpalm/aiorm
 def tearDownClass(cls):
     from aiorm.orm.declaration.meta import db
     db.pop('sample')
示例#7
0
文件: sample.py 项目: mardiros/aiorm
 def tearDownClass(cls):
     from aiorm.orm.declaration.meta import db
     db.pop('sample')