def test_bootstrap_migration_unsupported(self): ''' Raise an exception if the database type is not supported. ''' type_ = 'bogusdb' cursor = Mock() migration = 'sample_migration' with self.assertRaises(ValueError): agnostic._bootstrap_migration(type_, cursor, migration)
def test_bootstrap_migration(self): ''' Insert a migration into the migrations table. ''' type_ = 'postgres' cursor = Mock() migration = 'sample_migration' insert_re = re.compile(r'insert', flags=re.IGNORECASE) agnostic._bootstrap_migration(type_, cursor, migration) self.assertTrue(cursor.execute.called) self.assertRegex(cursor.execute.call_args[0][0], insert_re) self.assertIn('sample_migration', cursor.execute.call_args[0][1]) self.assertIn( agnostic.MIGRATION_STATUS_BOOTSTRAPPED, cursor.execute.call_args[0][1] )