예제 #1
0
    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')
예제 #2
0
    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)
예제 #3
0
    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)
예제 #4
0
 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)
예제 #5
0
    def test_default_model_config(self):
        db = manager.Manager(config=self.config)

        self.assertTrue(issubclass(db.Model, model.ModelBase))
예제 #6
0
    def test_custom_session(self):
        class MySession(Session):
            pass

        db = manager.Manager(session_class=MySession)
        self.assertIsInstance(db.session.session_factory(), MySession)
예제 #7
0
 def setUpClass(cls):
     cls.db = manager.Manager(Model=fixtures.Model, config=cls.config)