예제 #1
0
 def test_downgrade(self, mock_get_engine, mock_downgrade, mock_upgrade,
         mock_find_repo, mock_version):
     database = 'fake'
     migration.db_sync(1, database=database)
     mock_version.assert_called_once_with(database)
     mock_find_repo.assert_called_once_with(database)
     mock_get_engine.assert_called_once_with(database)
     mock_downgrade.assert_called_once_with('engine', 'repo', 1)
     self.assertFalse(mock_upgrade.called)
예제 #2
0
 def test_downgrade(self, mock_get_engine, mock_downgrade, mock_upgrade,
                    mock_find_repo, mock_version):
     database = 'fake'
     migration.db_sync(1, database=database)
     mock_version.assert_called_once_with(database, context=None)
     mock_find_repo.assert_called_once_with(database)
     mock_get_engine.assert_called_once_with(database, context=None)
     mock_downgrade.assert_called_once_with('engine', 'repo', 1)
     self.assertFalse(mock_upgrade.called)
예제 #3
0
 def test_downgrade(
     self, mock_get_engine, mock_downgrade, mock_upgrade, mock_sync_locked, mock_find_repo, mock_version
 ):
     database = "fake"
     migration.db_sync(1, database=database)
     mock_version.assert_called_once_with(database)
     mock_find_repo.assert_called_once_with(database)
     mock_get_engine.assert_called_once_with(database)
     mock_downgrade.assert_called_once_with("engine", "repo", 1)
     self.assertFalse(mock_upgrade.called)
예제 #4
0
    def test_innodb_tables(self):
        with mock.patch.object(sa_migration, "get_engine", return_value=self.migrate_engine):
            sa_migration.db_sync()

        total = self.migrate_engine.execute(
            "SELECT count(*) "
            "FROM information_schema.TABLES "
            "WHERE TABLE_SCHEMA = '%(database)s'" % {"database": self.migrate_engine.url.database}
        )
        self.assertTrue(total.scalar() > 0, "No tables found. Wrong schema?")

        noninnodb = self.migrate_engine.execute(
            "SELECT count(*) "
            "FROM information_schema.TABLES "
            "WHERE TABLE_SCHEMA='%(database)s' "
            "AND ENGINE != 'InnoDB' "
            "AND TABLE_NAME != 'migrate_version'" % {"database": self.migrate_engine.url.database}
        )
        count = noninnodb.scalar()
        self.assertEqual(count, 0, "%d non InnoDB tables created" % count)
예제 #5
0
    def test_innodb_tables(self):
        with mock.patch.object(sa_migration, 'get_engine',
                               return_value=self.migrate_engine):
            sa_migration.db_sync()

        total = self.migrate_engine.execute(
            "SELECT count(*) "
            "FROM information_schema.TABLES "
            "WHERE TABLE_SCHEMA = '%(database)s'" %
            {'database': self.migrate_engine.url.database})
        self.assertGreater(total.scalar(), 0, "No tables found. Wrong schema?")

        noninnodb = self.migrate_engine.execute(
            "SELECT count(*) "
            "FROM information_schema.TABLES "
            "WHERE TABLE_SCHEMA='%(database)s' "
            "AND ENGINE != 'InnoDB' "
            "AND TABLE_NAME != 'migrate_version'" %
            {'database': self.migrate_engine.url.database})
        count = noninnodb.scalar()
        self.assertEqual(count, 0, "%d non InnoDB tables created" % count)
예제 #6
0
 def db_sync(self, engine):
     with mock.patch.object(sa_migration, 'get_engine',
                            return_value=engine):
         sa_migration.db_sync(database='api')
예제 #7
0
 def db_sync(self, engine):
     with mock.patch.object(sa_migration, 'get_engine',
                            return_value=engine):
         sa_migration.db_sync()
 def db_sync(self, engine):
     with mock.patch.object(sa_migration, "get_engine", return_value=engine):
         sa_migration.db_sync(database="api")