Exemplo n.º 1
0
    def test_adding_kitty_participants_to_race(self):
        kitty_one = nya.Cat("desperado")
        kitty_two = nya.Cat("el niño")
        kitty_three = nya.Cat("catnip")
        kitty_four = nya.Cat("desperado")

        race = nya.NyaRace(500)
        race.add_kitty_participant(kitty_one)
        race.add_kitty_participant(kitty_two)
        race.add_kitty_participant(kitty_three)
        race.add_kitty_participant(kitty_four)
        self.assertEqual(4, len(race._kitty_participants))

        # Can't add kitties that are already racing
        kitty_racing = nya.Cat("already racing")
        kitty_racing.is_racing = True
        race.add_kitty_participant(kitty_racing)
        self.assertEqual(4, len(race._kitty_participants))
Exemplo n.º 2
0
    def test_cat_race(self):
        kitty_one = nya.Cat("desperado")
        kitty_one.food = 750
        kitty_one.agility = 5

        kitty_two = nya.Cat("el niño")
        kitty_two.food = 500
        kitty_two.agility = 10

        kitty_three = nya.Cat("catnip")
        kitty_three.food = 800
        kitty_three.agility = 4

        kitty_four = nya.Cat("hotail")
        kitty_four.food = 1000
        kitty_four.agility = 3

        race = nya.NyaRace(100)
        race.add_kitty_participant(kitty_one)
        race.add_kitty_participant(kitty_two)
        race.add_kitty_participant(kitty_three)
        race.add_kitty_participant(kitty_four)

        expected_results = (
            [kitty_four, kitty_three, kitty_one, kitty_two],
            [kitty_four, kitty_three, kitty_one, kitty_two],
            [kitty_four, kitty_three, kitty_one, kitty_two],
            [kitty_four, kitty_two, kitty_three, kitty_one],
            [kitty_four, kitty_two, kitty_three, kitty_one],
            [kitty_two, kitty_four, kitty_one, kitty_three],
            [kitty_two, kitty_one, kitty_three, kitty_four],
            [kitty_two, kitty_one, kitty_three, kitty_four],
            [kitty_two, kitty_one, kitty_three, kitty_four],
            [kitty_two, kitty_one, kitty_three, kitty_four],
        )

        received_results = tuple(race.step())
        print(expected_results)
        print(received_results)

        self.assertEqual(expected_results, received_results)
Exemplo n.º 3
0
    def test_cat_race(self):
        kitty_one = nya.Cat("desperado")
        kitty_one.food = 750
        kitty_one.agility = 5

        kitty_two = nya.Cat("el niño")
        kitty_two.food = 500
        kitty_two.agility = 10

        kitty_three = nya.Cat("catnip")
        kitty_three.food = 800
        kitty_three.agility = 4

        kitty_four = nya.Cat("hotail")
        kitty_four.food = 1000
        kitty_four.agility = 3

        race = nya.NyaRace(100)
        race.add_kitty_participant(kitty_one)
        race.add_kitty_participant(kitty_two)
        race.add_kitty_participant(kitty_three)
        race.add_kitty_participant(kitty_four)

        expected_results = (
            [
                kitty_four,
                kitty_three,
                kitty_one,
                kitty_two,
            ],
            [
                kitty_four,
                kitty_three,
                kitty_one,
                kitty_two,
            ],
            [
                kitty_four,
                kitty_three,
                kitty_one,
                kitty_two,
            ],
            [
                kitty_four,
                kitty_two,
                kitty_three,
                kitty_one,
            ],
            [
                kitty_four,
                kitty_two,
                kitty_three,
                kitty_one,
            ],
            [
                kitty_two,
                kitty_four,
                kitty_one,
                kitty_three,
            ],
            [
                kitty_two,
                kitty_one,
                kitty_three,
                kitty_four,
            ],
            [
                kitty_two,
                kitty_one,
                kitty_three,
                kitty_four,
            ],
            [
                kitty_two,
                kitty_one,
                kitty_three,
                kitty_four,
            ],
            [
                kitty_two,
                kitty_one,
                kitty_three,
                kitty_four,
            ],
        )

        for expected_state, race_state in zip(expected_results, race.step()):
            self.assertEqual(expected_state, race_state)
Exemplo n.º 4
0
 def test_race_participant_type(self):
     # race _kitty_participants should not be altered from it's original type.
     race_test = nya.NyaRace(500)
     self.assertEqual(type(race_test._kitty_participants), set)