Esempio n. 1
0
 def test_005_roster_add_pokemon(self):
     s = pokemon.Species(1, 'bulbasaur')
     p1 = pokemon.Pokemon(1, s)
     p2 = pokemon.Pokemon(2, s)
     t = pokemon.Team(1, 'basic team', first=p1)
     r = pokemon.Roster(pokemon=[p1], teams=[t], active_team_id=1)
     r.add_pokemon(p2)
     assert r.get_pokemon(2) == p2
Esempio n. 2
0
 def test_002_roster_add_team(self):
     s = pokemon.Species(1, 'bulbasaur')
     p = pokemon.Pokemon(1, s)
     t1 = pokemon.Team(1, 'basic team', first=p)
     t2 = pokemon.Team(2, 'another team', first=p)
     r = pokemon.Roster(pokemon=[p], teams=[t1], active_team_id=1)
     r.add_team(t2)
     assert r.get_team(2) == t2
Esempio n. 3
0
 def test_006_roster_remove_pokemon(self):
     s = pokemon.Species(1, 'bulbasaur')
     p1 = pokemon.Pokemon(1, s)
     p2 = pokemon.Pokemon(2, s)
     t = pokemon.Team(1, 'basic team', first=p1, second=p2)
     r = pokemon.Roster(pokemon=[p1, p2], teams=[t], active_team_id=1)
     r.remove_pokemon(p2)
     self.assertRaises(KeyError, r.get_pokemon, 2)
     assert t.get_position(2) is None
Esempio n. 4
0
 def test_004_roster_remove_team_resets_active_team_id(self):
     s = pokemon.Species(1, 'bulbasaur')
     p = pokemon.Pokemon(1, s)
     t1 = pokemon.Team(1, 'basic team', first=p)
     t2 = pokemon.Team(2, 'another team', first=p)
     r = pokemon.Roster(pokemon=[p], teams=[t1, t2], active_team_id=2)
     r.remove_team(t2)
     assert r.active_team() is None
     self.assertRaises(KeyError, r.get_team, 2)
Esempio n. 5
0
 def test_007_roster_to_dict(self):
     s = pokemon.Species(1, 'bulbasaur')
     p = pokemon.Pokemon(1, s)
     t1 = pokemon.Team(1, 'basic team', first=p)
     r = pokemon.Roster(pokemon=[p], teams=[t1], active_team_id=1)
     expected = {
         'pokemon': [p.to_dict()],
         'teams': [t1.to_dict()],
         'active_team': 1
     }
     assert r.to_dict() == expected
Esempio n. 6
0
 def test_001_roster_active_team(self):
     s = pokemon.Species(1, 'bulbasaur')
     p = pokemon.Pokemon(1, s)
     t1 = pokemon.Team(1, 'basic team', first=p)
     t2 = pokemon.Team(2, 'another team', first=p)
     r = pokemon.Roster(pokemon=[p], teams=[t1, t2], active_team_id=1)
     assert r.active_team() == t1
     r.set_active_team(2)
     assert r.active_team() == t2
     r.set_active_team(None)
     assert r.active_team() is None
Esempio n. 7
0
    def test_009_roster_from_dict(self):
        mock_pokeapi_calls()
        s = pokemon.Species(1, 'bulbasaur')
        p = pokemon.Pokemon(1, s)
        t1 = pokemon.Team(1, 'basic team', first=p)
        t2 = pokemon.Team(2, 'another team', first=p)
        r = pokemon.Roster(pokemon=[p], teams=[t1, t2], active_team_id=2)
        reloaded = pokemon.Roster.from_dict(r.to_dict())
        p_reloaded = reloaded.get_pokemon(1)

        assert r == reloaded
        assert reloaded.teams[1].get_position(1) is p_reloaded
        assert reloaded.teams[2].get_position(1) is p_reloaded
Esempio n. 8
0
 def test_000_roster_minimal(self):
     r = pokemon.Roster()
     assert r.active_team() is None
     assert r.pokemon == {}
     assert r.teams == {}