def setUp(self): self.connection = self.bind.connect() self.context = migration.MigrationContext.configure( connection=self.connection, opts={"version_table": "version_table"}) version_table.create(self.connection) self.updater = migration.HeadMaintainer(self.context, ())
def test_get_heads(self): version_table.create(self.connection) context = self.make_one(connection=self.connection, opts={'version_table': 'version_table'}) updater = migration.HeadMaintainer(context, ()) updater.update_to_step(_up(None, 'a', True)) updater.update_to_step(_up(None, 'b', True)) eq_(context.get_current_heads(), ('a', 'b'))
def test_get_heads(self): version_table.create(self.connection) context = self.make_one(connection=self.connection, opts={"version_table": "version_table"}) updater = migration.HeadMaintainer(context, ()) updater.update_to_step(_up(None, "a", True)) updater.update_to_step(_up(None, "b", True)) eq_(context.get_current_heads(), ("a", "b"))
def test_get_current_revision_multiple_heads(self): version_table.create(self.connection) context = self.make_one(connection=self.connection, opts={'version_table': 'version_table'}) updater = migration.HeadMaintainer(context, ()) updater.update_to_step(_up(None, 'a', True)) updater.update_to_step(_up(None, 'b', True)) assert_raises_message( CommandError, "Version table 'version_table' has more than one head present; " "please use get_current_heads()", context.get_current_revision)