Пример #1
0
    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)
Пример #2
0
    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)
Пример #3
0
 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)
Пример #4
0
    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)
Пример #5
0
    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)
Пример #6
0
    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)
Пример #7
0
    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)
Пример #8
0
    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)
Пример #9
0
    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)
Пример #10
0
    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)
Пример #11
0
    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)
Пример #12
0
    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)
Пример #13
0
    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)
Пример #14
0
    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)
Пример #15
0
    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)
Пример #16
0
 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)
Пример #17
0
 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)
Пример #18
0
 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)