示例#1
0
 def test_player_classmethod_get_player_url_success(self):
     assert (Player("Nathan Brown")._get_player_url() ==
             "https://afltables.com/afl/stats/players/N/Nathan_Brown0.html")
     assert (Player("Nick Riewoldt")._get_player_url() ==
             "https://afltables.com/afl/stats/players/N/Nick_Riewoldt.html")
     assert (Player("Tony Lockett")._get_player_url() ==
             "https://afltables.com/afl/stats/players/T/Tony_Lockett.html")
示例#2
0
    def _get_players(self):
        """
        Returns a list of pyAFL.Player objects for all players contained in `self.all_time_players_url`

        Returns
        ----------
            players : list
                list of pyAFL.Player objects

        """
        resp = requests.get(self.all_time_players_url)
        soup = BeautifulSoup(resp.text, "html.parser")

        player_table = soup.find("table")
        player_table_body = player_table.find("tbody")
        player_anchor_tags = player_table_body.findAll("a")

        players = [
            Player(player.text, url=player.attrs.get("href"))
            for player in player_anchor_tags
        ]

        return players
示例#3
0
 def test_player_name_none_throws_exception(self):
     with pytest.raises(TypeError):
         Player()
示例#4
0
    def test_player_classmethod_get_player_stats(self):
        player = Player("Nick Riewoldt")

        assert isinstance(player.get_player_stats(), PlayerStats)
示例#5
0
    def test_player_classmethod_get_player_url_failure(self):
        with pytest.raises(LookupError) as e:
            Player("Babe Ruth")._get_player_url()

        assert "Found no players with name" in str(e)