Skip to content

Commit 79d8136

Browse files
authored
Add end-to-end test (#256)
1 parent d34f3ef commit 79d8136

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

scripts/build.sh

+5-2
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,15 @@ function main() {
3838
"${poetry_program_path}" install
3939
if [[ "0" != "$?" ]]; then printf "Cannot execute poetry at ${poetry_program_path}\n" && exit 255; fi
4040

41-
# TODO: @jaebradley re-enable pytests
42-
"${poetry_program_path}" run coverage run --source=basketball_reference_web_scraper --module pytest --ignore "./tests" && coverage report --show-missing
41+
# TODO: @jaebradley re-enable integration pytests
42+
"${poetry_program_path}" run coverage run --source=basketball_reference_web_scraper --module pytest --ignore "./tests/integration"
4343
local poetry_exit_code="$?"
4444
# https://docs.pytest.org/en/7.1.x/reference/exit-codes.html#:~:text=Exit%20code%205,No%20tests%20were%20collected&text=If%20you%20would%20like%20to,using%20the%20pytest%2Dcustom_exit_code%20plugin.
4545
if [[ "5" == "${poetry_exit_code}" ]]; then printf "pytest using poetry program at ${poetry_program_path} did not collect any tests" && exit 0; fi
4646
if [[ "0" != "${poetry_exit_code}" ]]; then printf "Cannot run pytest using poetry program at ${poetry_program_path}\n" && exit 255; fi
47+
48+
"${poetry_program_path}" run coverage report --show-missing
49+
if [[ "0" != "$?" ]]; then printf "Cannot run coverage report program at ${poetry_program_path}\n" && exit 255; fi
4750
}
4851

4952
main "$@"

tests/end to end/__init__.py

Whitespace-only changes.

tests/end to end/test_client.py

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
from unittest import TestCase
2+
3+
from basketball_reference_web_scraper import client
4+
from basketball_reference_web_scraper.data import Location, Team, Outcome
5+
6+
7+
class TestPlayerBoxScores(TestCase):
8+
def test(self):
9+
box_scores = client.player_box_scores(day=11, month=3, year=2024)
10+
self.assertIsNotNone(box_scores)
11+
self.assertNotEqual(0, len(box_scores))
12+
self.assertEqual(124, len(box_scores))
13+
self.assertEqual({
14+
"name": "Nikola Jokić",
15+
"slug": "jokicni01",
16+
"team": Team.DENVER_NUGGETS,
17+
"opponent": Team.TORONTO_RAPTORS,
18+
"location": Location.HOME,
19+
"outcome": Outcome.WIN,
20+
"seconds_played": 2286,
21+
"made_field_goals": 14,
22+
"attempted_field_goals": 26,
23+
"made_three_point_field_goals": 1,
24+
"attempted_three_point_field_goals": 3,
25+
"made_free_throws": 6,
26+
"attempted_free_throws": 6,
27+
"offensive_rebounds": 6,
28+
"defensive_rebounds": 11,
29+
"assists": 12,
30+
"steals": 6,
31+
"blocks": 2,
32+
"turnovers": 2,
33+
"personal_fouls": 3,
34+
"game_score": 42.5,
35+
},
36+
box_scores[0])

0 commit comments

Comments
 (0)