def setUp(self): self.db = manager.Manager(config=self.config, Model=self.Model) self.db.create_all() self.engine0 = self.db.engine self.engine1 = self.db.get_engine('bind1') self.engine2 = self.db.get_engine('bind2')
def test_reflect(self): """Test that existing database tables can be reflected.""" rdb = manager.Manager( config={'SQLALCHEMY_DATABASE_URI': self.config.binds[0]}) self.assertEqual(len(rdb.metadata.tables), 0) rdb.reflect() self.assertEqual(len(rdb.metadata.tables), 1) self.assertIn('bind0', rdb.metadata.tables)
def test_create_drop_all(self): db = manager.Manager(Model=fixtures.Model, config=self.config) db.create_all() self.assertTrue(len(self.models) > 0) self.assertModelTablesExist(db.engine) db.drop_all() self.assertModelTablesNotExists(db.engine)
def test_drop_all_exception(self): # pass in dummy value for Model db = manager.Manager(Model=False, config=self.config) self.assertRaises(UnmappedError, db.drop_all)
def test_default_model_config(self): db = manager.Manager(config=self.config) self.assertTrue(issubclass(db.Model, model.ModelBase))
def test_custom_session(self): class MySession(Session): pass db = manager.Manager(session_class=MySession) self.assertIsInstance(db.session.session_factory(), MySession)
def setUpClass(cls): cls.db = manager.Manager(Model=fixtures.Model, config=cls.config)