def test_does_not_convert_if_item_is_revealed(self): self.pkmn_sets_mock.standard_battle_sets = {} self.get_mega_name_mock.return_value = 'venusaurmega' pkmn = Pokemon('venusaur', 100) pkmn.item = 'leftovers' pkmn.try_convert_to_mega() self.assertEqual("venusaur", pkmn.name)
def test_does_not_convert_if_item_is_none(self): self.pkmn_sets_mock.pokemon_sets = {} self.get_mega_name_mock.return_value = 'venusaurmega' pkmn = Pokemon('venusaur', 100) pkmn.item = None pkmn.try_convert_to_mega() self.assertEqual("venusaur", pkmn.name)
def test_guesses_most_likely_item(self): self.get_sets_mock.return_value = { constants.ITEMS: { "item_one": 10, "item_two": 9 } } p = Pokemon('pikachu', 100) p.item = constants.UNKNOWN_ITEM p.update_item_for_random_battles() self.assertEqual("item_one", p.item)
def test_gets_revealed_item_when_item_is_revealed(self): p = Pokemon('pikachu', 100) p.item = 'lightball' items = [ ('lightball', 50), ('leftovers', 50), ] possible_items = p.get_possible_items(items) expected_items = ['lightball'] self.assertEqual(expected_items, possible_items)
def test_gets_two_items_when_they_are_equally_likely(self): p = Pokemon('pikachu', 100) p.item = constants.UNKNOWN_ITEM items = [ ('lightball', 50), ('other_item', 50), ] possible_items = p.get_possible_items(items) expected_items = ['lightball', 'other_item'] self.assertEqual(expected_items, possible_items)
def test_gets_none_when_item_is_none(self): p = Pokemon('pikachu', 100) p.item = None items = [ ('lightball', 50), ('leftovers', 50), ] possible_items = p.get_possible_items(items) expected_items = [None] self.assertEqual(expected_items, possible_items)
def test_guesses_assultvest_when_can_have_assultvest_flag_is_true(self): p = Pokemon('pikachu', 100) p.item = constants.UNKNOWN_ITEM p.can_have_assaultvest = True items = [ ('lightball', 50), ('assaultvest', 50), ] possible_items = p.get_possible_items(items) expected_items = ['lightball', 'assaultvest'] self.assertEqual(expected_items, possible_items)
def test_stops_once_cumulative_percentage_exceeds_limit(self): p = Pokemon('pikachu', 100) p.item = constants.UNKNOWN_ITEM items = [ ('lightball', 50), ('other_item', 30), ('another_item', 20), ] possible_items = p.get_possible_items(items) expected_items = ['lightball', 'other_item'] self.assertEqual(expected_items, possible_items)
def test_works_with_one_item(self): p = Pokemon('pikachu', 100) p.item = constants.UNKNOWN_ITEM items = [ ('lightball', 100), ] possible_items = p.get_possible_items(items) expected_items = [ 'lightball', ] self.assertEqual(expected_items, possible_items)
def test_does_not_guess_lifeorb_when_can_have_lifeorb_is_false(self): p = Pokemon('pikachu', 100) p.item = constants.UNKNOWN_ITEM p.can_have_life_orb = False items = [ ('lifeorb', 50), ('lightball', 50), # should be guessed because flag is set to True ] possible_items = p.get_possible_items(items) expected_items = ['lightball'] self.assertEqual(expected_items, possible_items)
def test_guesses_choiceband_when_can_not_have_band_is_false(self): p = Pokemon('pikachu', 100) p.item = constants.UNKNOWN_ITEM p.can_not_have_band = False items = [ ('lightball', 50), ('choiceband', 50), # should NOT be ignored because flag is set to False ] possible_items = p.get_possible_items(items) expected_items = ['lightball', 'choiceband'] self.assertEqual(expected_items, possible_items)
def test_ignores_item_in_pass_items(self): p = Pokemon('pikachu', 100) p.item = constants.UNKNOWN_ITEM items = [ ('lightball', 50), ('leftovers', 50), # leftovers is ignored because it reveals itself ] possible_items = p.get_possible_items(items) expected_items = [ 'lightball', ] self.assertEqual(expected_items, possible_items)
def test_guesses_choice_item_when_can_have_choice_item_flag_is_true(self): p = Pokemon('pikachu', 100) p.item = constants.UNKNOWN_ITEM p.can_have_choice_item = True items = [ ('lightball', 50), ('choiceband', 50), # should be guessed because flag is set to True ] possible_items = p.get_possible_items(items) expected_items = ['lightball', 'choiceband'] self.assertEqual(expected_items, possible_items)
def test_can_not_have_choice_specs_flag_does_not_affect_choice_band_guess( self): p = Pokemon('pikachu', 100) p.item = constants.UNKNOWN_ITEM p.can_not_have_specs = True p.can_not_have_band = False items = [ ('lightball', 50), ('choiceband', 50), # should NOT be ignored because flag is set to False # choice_specs flag doesn't matter ] possible_items = p.get_possible_items(items) expected_items = ['lightball', 'choiceband'] self.assertEqual(expected_items, possible_items)
def test_does_not_guess_assultvest_when_can_have_assultvest_flag_is_false( self): p = Pokemon('pikachu', 100) p.item = constants.UNKNOWN_ITEM p.can_have_assaultvest = False items = [ ('lightball', 50), ('assaultvest', 50), # should be ignored because flag is set to False ] possible_items = p.get_possible_items(items) expected_items = [ 'lightball', ] self.assertEqual(expected_items, possible_items)
def test_gets_item_when_item_is_unknown(self): p = Pokemon('pikachu', 100) p.item = constants.UNKNOWN_ITEM p.update_item_for_random_battles() self.assertNotEqual(p.item, constants.UNKNOWN_ITEM)
def test_does_not_guess_item_when_it_exists(self): p = Pokemon('pikachu', 100) p.item = 'some_item' p.update_item_for_random_battles() self.assertEqual('some_item', p.item)
def test_does_not_guess_item_when_it_is_none(self): p = Pokemon('pikachu', 100) p.item = None p.update_item_for_random_battles() self.assertIsNone(p.item)