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))
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])
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))
def tearDown(self) -> None: t_objs = fetch_all(Migrate1) [obj.remove_entry() for obj in t_objs] _drop_table('test.db', 'migrate1')
def testFetchAllPagination(self): t_objs = fetch_all(FetchClass, 1, 10) self.assertEqual(tuple(self.objs[:10]), t_objs)
def testFetchAll(self): t_objs = fetch_all(FetchClass) self.assertEqual(tuple(self.objs), t_objs)
def testMassCreate(self): create_many(self.objs, protect_memory=False) _objs = fetch_all(MassCommit) self.assertEqual(_objs, tuple(self.objs))