Ejemplo n.º 1
0
    def test_sqlite_setup_teardown(self):

        fixture = test_fixtures.AdHocDbFixture("sqlite:///foo.db")

        fixture.setUp()

        self.assertEqual(
            str(enginefacade._context_manager._factory._writer_engine.url),
            "sqlite:///foo.db")

        self.assertTrue(os.path.exists("foo.db"))
        fixture.cleanUp()

        self.assertFalse(os.path.exists("foo.db"))
Ejemplo n.º 2
0
    def test_mysql_setup_teardown(self):
        try:
            mysql_backend = provision.Backend.backend_for_database_type(
                "mysql")
        except exception.BackendNotAvailable:
            self.skip("mysql backend not available")

        mysql_backend.create_named_database("adhoc_test")
        self.addCleanup(mysql_backend.drop_named_database, "adhoc_test")
        url = str(mysql_backend.provisioned_database_url("adhoc_test"))

        fixture = test_fixtures.AdHocDbFixture(url)

        fixture.setUp()

        self.assertEqual(
            str(enginefacade._context_manager._factory._writer_engine.url),
            url)

        fixture.cleanUp()