def do_delete(self, args): try: doParser = self.arg_delete() doArgs = doParser.parse_args(shlex.split(args)) if not doArgs: return 2 # call UForge API printer.out("Retrieving migration with id [" + doArgs.id + "]...") migration = self.api.Users(self.login).Migrations(doArgs.id).Get() if migration is None: printer.out("No migration available with id " + doArgs.id) return 2 print migration_utils.migration_table([migration]).draw() + "\n" if doArgs.no_confirm or generics_utils.query_yes_no( "Do you really want to delete migration with id " + doArgs.id + "?"): printer.out("Please wait...") self.api.Users(self.login).Migrations(doArgs.id).Delete() printer.out("Migration deleted", printer.OK) except ArgumentParserError as e: printer.out("ERROR: In Arguments: " + str(e), printer.ERROR) self.help_delete() except Exception as e: return hammr_utils.handle_uforge_exception(e)
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 do_list(self, args): try: # call UForge API printer.out("Getting migrations for [" + self.login + "] ...") migrations = self.api.Users(self.login).Migrations.Getall() migrations = migrations.migrations.migration if len(migrations) == 0: printer.out("No migrations available") return print migration_utils.migration_table(migrations).draw() + "\n" except ArgumentParserError as e: printer.out("ERROR: In Arguments: " + str(e), printer.ERROR) self.help_list() except Exception as e: return hammr_utils.handle_uforge_exception(e)