Exemplo n.º 1
0
    def testMassCreate(self):
        with connect('other.db') as con:
            cur = con.cursor()
            cur.execute(
                f'CREATE TABLE IF NOT EXISTS MASSCOMMIT (obj_id, str_)')

        start_tup = fetch_all(MassCommit)
        create_many(self.objs, protect_memory=False)
        _objs = fetch_all(MassCommit)
        self.assertEqual(_objs, start_tup + tuple(self.objs))
Exemplo n.º 2
0
 def testBasicMigrate(self):
     global Migrate1, Migrate2
     Migrate1 = Migrate2
     Migrate1.__name__ = 'Migrate1'
     basic_migrate(Migrate1, {'ordinal': 'cardinal'})
     t_objs = fetch_all(Migrate1)
     self.assertEqual([obj.ordinal for obj in self.objs],
                      [obj.cardinal for obj in t_objs])
     self.assertEqual(["default" for _ in range(10)],
                      [obj.str_ for obj in t_objs])
Exemplo n.º 3
0
 def testMassCopy(self):
     setattr(MassCommit, 'db_path', 'other.db')
     start_tup = fetch_all(MassCommit)
     copy_many(self.objs, 'other.db', False)
     tup = fetch_all(MassCommit)
     self.assertEqual(tup, start_tup + tuple(self.objs))
Exemplo n.º 4
0
 def tearDown(self) -> None:
     t_objs = fetch_all(Migrate1)
     [obj.remove_entry() for obj in t_objs]
     _drop_table('test.db', 'migrate1')
Exemplo n.º 5
0
 def testFetchAllPagination(self):
     t_objs = fetch_all(FetchClass, 1, 10)
     self.assertEqual(tuple(self.objs[:10]), t_objs)
Exemplo n.º 6
0
 def testFetchAll(self):
     t_objs = fetch_all(FetchClass)
     self.assertEqual(tuple(self.objs), t_objs)
Exemplo n.º 7
0
 def testMassCreate(self):
     create_many(self.objs, protect_memory=False)
     _objs = fetch_all(MassCommit)
     self.assertEqual(_objs, tuple(self.objs))