def test_team_attack_deaths(): team_one = SuperHeroes.Team("One") jodie = SuperHeroes.Hero("Jodie Foster") aliens = SuperHeroes.Ability("Alien Friends", 10000) jodie.add_ability(aliens) team_one.add_hero(jodie) team_two = SuperHeroes.Team("Two") athena = SuperHeroes.Hero("Athena") socks = SuperHeroes.Armor("Socks", 10) athena.add_armor(socks) team_two.add_hero(athena) assert team_two.heroes[0].deaths == 0 team_one.attack(team_two) assert team_two.heroes[0].deaths == 1
def test_team_remove_unlisted(): # Test that if no results found return 0 team = SuperHeroes.Team("One") jodie = SuperHeroes.Hero("Jodie Foster") team.add_hero(jodie) code = team.remove_hero("Athena") assert code == 0
def test_team_remove_hero(): team = SuperHeroes.Team("One") jodie = SuperHeroes.Hero("Jodie Foster") team.add_hero(jodie) assert team.heroes[0].name == "Jodie Foster" team.remove_hero("Jodie Foster") assert len(team.heroes) == 0
def test_print_heroes(): team = SuperHeroes.Team("One") jodie = SuperHeroes.Hero("Jodie Foster") team.add_hero(jodie) athena = SuperHeroes.Hero("Athena") team.add_hero(athena) output_string = capture_console_output(team.view_all_heroes) assert "Jodie Foster" in output_string assert "Athena" in output_string
def create_team(heroes=[]): teams = [ "Orchids", "Red", "Blue", "Cheese Steaks", "Warriors", "49ers", "Marvel", "DC", "Rat Pack", "The Little Red Riding Hoods", "Team One", "Generic Team", "X-men", "Team Two", "Golden Champions", "Vegan Protectors", "The Cardinals", "Winky Bears", "Steelsmiths", "Boilermakers", "Nincompoops" ] name = teams[random.randint(0, len(teams) - 1)] team = SuperHeroes.Team(name) if len(heroes) > 0: for member in heroes: team.add_hero(member) return team
def test_revive_heroes(): heroes = [] for _ in range(0, 20): heroes.append(create_hero(health=60)) team_one = SuperHeroes.Team("One") for hero in heroes: team_one.add_hero(hero) team_one.defend(300) for hero in team_one.heroes: assert hero.health == 45 team_one.revive_heroes() for hero in team_one.heroes: assert hero.health == 60
def test_team_defend(): heroes = [] for _ in range(0, 20): heroes.append(create_hero(health=20)) print(heroes[_].health) team_one = SuperHeroes.Team("One") for hero in heroes: team_one.add_hero(hero) deaths = team_one.defend(100) for hero in team_one.heroes: assert hero.health == 15 assert deaths == 0 assert team_one.defend(400) == 20
def test_find_empty_hero(): team = SuperHeroes.Team("One") assert team.find_hero("Alexa") == 0
def test_find_unlisted_hero(): team = SuperHeroes.Team("One") jodie = SuperHeroes.Hero("Jodie Foster") team.add_hero(jodie) assert team.find_hero("Alexa") == 0
def test_find_hero(): team = SuperHeroes.Team("One") jodie = SuperHeroes.Hero("Jodie Foster") team.add_hero(jodie) hero = team.find_hero("Jodie Foster") assert hero.name == "Jodie Foster"
def test_team_remove_empty_list(): team = SuperHeroes.Team("One") assert team.remove_hero("Athena") == 0
def test_team_name(): team = SuperHeroes.Team("One") assert team.name == "One"
def test_team_instance(): team = SuperHeroes.Team("One") assert team