def test_migration_table_return_the_list_of_migrations_when_there_are_migrations( self, mock_api_getall, mock_migration_table): # given m = migration.Migration() m.api = Api("url", username="******", password="******", headers=None, disable_ssl_certificate_validation=False, timeout=constants.HTTP_TIMEOUT) m.login = "******" m.password = "******" migrations = uforge.migrations() migrations.migrations = pyxb.BIND() migration1 = self.create_migration(1, "a migration", 50, "In Progress", False, False, False) migrations.migrations.append(migration1) mock_api_getall.return_value = migrations # when m.do_list("") # then mock_migration_table.assert_called_with( migrations.migrations.migration)
def test_migration_table_add_the_migration_cancelled_in_the_table(self, mock_table_add_row): # given migrations = uforge.migrations() migrations.migrations = pyxb.BIND() migration1 = self.create_migration(1, "a migration", 50, "Cancelled", False, False, True) migrations.migrations.append(migration1) # when migration_utils.migration_table(migrations.migrations.migration) # then self.assertEquals(mock_table_add_row.call_count, 1) mock_table_add_row.assert_any_call([1, "a migration", "Cancelled"])
def test_migration_table_add_all_migration_in_progress_in_the_table(self, mock_table_add_row): # given migrations = uforge.migrations() migrations.migrations = pyxb.BIND() migration1 = self.create_migration(1, "a migration", 50, "In Progress", False, False, False) migrations.migrations.append(migration1) migration2 = self.create_migration(2, "a second migration", 55, "In Progress", False, False, False) migrations.migrations.append(migration2) # when migration_utils.migration_table(migrations.migrations.migration) # then self.assertEquals(mock_table_add_row.call_count, 2) mock_table_add_row.assert_any_call([1, "a migration", "In Progress (50%)"]) mock_table_add_row.assert_any_call([2, "a second migration", "In Progress (55%)"])
def test_do_list_return_no_migration_message_when_there_is_no_migration(self, mock_api_getall, mock_message, mock_migration_table): # given m = migration.Migration() m.api = Api("url", username="******", password="******", headers=None, disable_ssl_certificate_validation=False, timeout=constants.HTTP_TIMEOUT) m.login = "******" m.password = "******" migrations = uforge.migrations() migrations.migrations = pyxb.BIND() mock_api_getall.return_value = migrations # when m.do_list("") # then mock_message.assert_called_with("No migrations available") mock_migration_table(ANY).assert_not_called()
def test_do_list_return_no_migration_message_when_there_is_no_migration(self, mock_api_getall, mock_message, mock_migration_table): # given m = migration.Migration() m.api = Api("url", username="******", password="******", headers=None, disable_ssl_certificate_validation=False, timeout=constants.HTTP_TIMEOUT) m.login = "******" m.password = "******" migrations = uforge.migrations() migrations.migrations = pyxb.BIND() mock_api_getall.return_value = migrations # when m.do_list("") # then mock_message.assert_called_with("No migrations available") mock_migration_table(ANY).assert_not_called()
def test_migration_table_return_the_list_of_migrations_when_there_are_migrations(self, mock_api_getall, mock_migration_table): # given m = migration.Migration() m.api = Api("url", username="******", password="******", headers=None, disable_ssl_certificate_validation=False, timeout=constants.HTTP_TIMEOUT) m.login = "******" m.password = "******" migrations = uforge.migrations() migrations.migrations = pyxb.BIND() migration1 = self.create_migration(1, "a migration", 50, "In Progress", False, False, False) migrations.migrations.append(migration1) mock_api_getall.return_value = migrations # when m.do_list("") # then mock_migration_table.assert_called_with(migrations.migrations.migration)