diff --git a/src/iracingdataapi/client.py b/src/iracingdataapi/client.py index 592f5c0..462b5a9 100644 --- a/src/iracingdataapi/client.py +++ b/src/iracingdataapi/client.py @@ -855,7 +855,7 @@ def result_season_results( payload = {"season_id": season_id} if event_type: payload["event_type"] = event_type - if race_week_num: + if race_week_num is not None: payload["race_week_num"] = race_week_num return self._get_resource("/data/results/season_results", payload=payload) @@ -1067,11 +1067,11 @@ def stats_season_driver_standings( """ payload = {"season_id": season_id, "car_class_id": car_class_id} - if race_week_num: + if race_week_num is not None: payload["race_week_num"] = race_week_num if club_id: payload["club_id"] = club_id - if division: + if division is not None: payload["division"] = division resource = self._get_resource( @@ -1102,11 +1102,11 @@ def stats_season_supersession_standings( """ payload = {"season_id": season_id, "car_class_id": car_class_id} - if race_week_num: + if race_week_num is not None: payload["race_week_num"] = race_week_num if club_id: payload["club_id"] = club_id - if division: + if division is not None: payload["division"] = division resource = self._get_resource( @@ -1122,14 +1122,14 @@ def stats_season_team_standings( Args: season_id (int): The iRacing season id. car_class_id (int): the iRacing car class id. - race_week_num (int): the race week number (0-12). Default 0. + race_week_num (int): the race week number (0-12). Returns: dict: a dict containing the season team standings """ payload = {"season_id": season_id, "car_class_id": car_class_id} - if race_week_num: + if race_week_num is not None: payload["race_week_num"] = race_week_num resource = self._get_resource( @@ -1150,7 +1150,7 @@ def stats_season_tt_standings( Args: season_id (int): The iRacing season id. car_class_id (int): the iRacing car class id. - race_week_num (int): the race week number (0-12). Default 0. + race_week_num (int): the race week number (0-12). club_id (int): the iRacing club id. division (int): the iRacing division. @@ -1159,11 +1159,11 @@ def stats_season_tt_standings( """ payload = {"season_id": season_id, "car_class_id": car_class_id} - if race_week_num: + if race_week_num is not None: payload["race_week_num"] = race_week_num if club_id: payload["club_id"] = club_id - if division: + if division is not None: payload["division"] = division resource = self._get_resource( @@ -1184,7 +1184,7 @@ def stats_season_tt_results( Args: season_id (int): The iRacing season id. car_class_id (int): the iRacing car class id. - race_week_num (int): the race week number (0-12). Default 0. + race_week_num (int): the race week number (0-12). club_id (int): the iRacing club id. division (int): the iRacing division. @@ -1199,7 +1199,7 @@ def stats_season_tt_results( } if club_id: payload["club_id"] = club_id - if division: + if division is not None: payload["division"] = division resource = self._get_resource("/data/stats/season_tt_results", payload=payload) @@ -1218,7 +1218,7 @@ def stats_season_qualify_results( Args: season_id (int): The iRacing season id. car_class_id (int): the iRacing car class id. - race_week_num (int): the race week number (0-12). Default 0. + race_week_num (int): the race week number (0-12). club_id (int): the iRacing club id. division (int): the iRacing division. @@ -1233,7 +1233,7 @@ def stats_season_qualify_results( } if club_id: payload["club_id"] = club_id - if division: + if division is not None: payload["division"] = division resource = self._get_resource( diff --git a/tests.py b/tests.py index 636f805..3d834e6 100644 --- a/tests.py +++ b/tests.py @@ -1162,6 +1162,14 @@ def test_result_season_results(self, mock_get_resource): ) self.assertEqual(result, mock_get_resource.return_value) + self.client.result_season_results( + season_id, event_type=event_type, race_week_num=0 + ) + expected_payload["race_week_num"] = 0 + mock_get_resource.assert_called_with( + "/data/results/season_results", payload=expected_payload + ) + @patch.object(irDataClient, "_get_resource") @patch.object(irDataClient, "_get_resource_or_link") def test_member_awards(self, mock_get_resource_or_link, mock_get_resource): @@ -1307,6 +1315,20 @@ def test_stats_season_driver_standings(self, mock_get_chunks, mock_get_resource) mock_get_chunks.assert_called_once() self.assertEqual(result, mock_get_chunks.return_value) + # test for 0 inputs which used to remove the input + self.client.stats_season_driver_standings( + season_id=season_id, car_class_id=car_class_id, race_week_num=0, division=0 + ) + mock_get_resource.assert_called_with( + "/data/stats/season_driver_standings", + payload={ + "season_id": season_id, + "car_class_id": car_class_id, + "race_week_num": 0, + "division": 0, + }, + ) + @patch.object(irDataClient, "_get_resource") @patch.object(irDataClient, "_get_chunks") def test_stats_season_supersession_standings( @@ -1328,6 +1350,20 @@ def test_stats_season_supersession_standings( mock_get_chunks.assert_called_once() self.assertEqual(result, mock_get_chunks.return_value) + # test for 0 inputs which used to remove the input + self.client.stats_season_supersession_standings( + season_id=season_id, car_class_id=car_class_id, race_week_num=0, division=0 + ) + mock_get_resource.assert_called_with( + "/data/stats/season_supersession_standings", + payload={ + "season_id": season_id, + "car_class_id": car_class_id, + "race_week_num": 0, + "division": 0, + }, + ) + @patch.object(irDataClient, "_get_resource") @patch.object(irDataClient, "_get_chunks") def test_stats_season_team_standings(self, mock_get_chunks, mock_get_resource): @@ -1345,6 +1381,19 @@ def test_stats_season_team_standings(self, mock_get_chunks, mock_get_resource): mock_get_chunks.assert_called_once() self.assertEqual(result, mock_get_chunks.return_value) + self.client.stats_season_team_standings( + season_id, car_class_id, race_week_num=0 + ) + + mock_get_resource.assert_called_with( + "/data/stats/season_team_standings", + payload={ + "season_id": season_id, + "car_class_id": car_class_id, + "race_week_num": 0, + }, + ) + @patch.object(irDataClient, "_get_resource") @patch.object(irDataClient, "_get_chunks") def test_stats_season_tt_standings(self, mock_get_chunks, mock_get_resource): @@ -1362,6 +1411,20 @@ def test_stats_season_tt_standings(self, mock_get_chunks, mock_get_resource): mock_get_chunks.assert_called_once() self.assertEqual(result, mock_get_chunks.return_value) + self.client.stats_season_tt_standings( + season_id, car_class_id, race_week_num=0, division=0 + ) + + mock_get_resource.assert_called_with( + "/data/stats/season_tt_standings", + payload={ + "season_id": season_id, + "car_class_id": car_class_id, + "race_week_num": 0, + "division": 0, + }, + ) + @patch.object(irDataClient, "_get_resource") @patch.object(irDataClient, "_get_chunks") def test_stats_season_tt_results(self, mock_get_chunks, mock_get_resource): @@ -1386,6 +1449,20 @@ def test_stats_season_tt_results(self, mock_get_chunks, mock_get_resource): mock_get_chunks.assert_called_once() self.assertEqual(result, mock_get_chunks.return_value) + self.client.stats_season_tt_results( + season_id, car_class_id, race_week_num, division=0 + ) + + mock_get_resource.assert_called_with( + "/data/stats/season_tt_results", + payload={ + "season_id": season_id, + "car_class_id": car_class_id, + "race_week_num": race_week_num, + "division": 0, + }, + ) + @patch.object(irDataClient, "_get_resource") @patch.object(irDataClient, "_get_chunks") def test_stats_season_qualify_results(self, mock_get_chunks, mock_get_resource): @@ -1410,6 +1487,20 @@ def test_stats_season_qualify_results(self, mock_get_chunks, mock_get_resource): mock_get_chunks.assert_called_once() self.assertEqual(result, mock_get_chunks.return_value) + self.client.stats_season_qualify_results( + season_id, car_class_id, race_week_num, division=0 + ) + + mock_get_resource.assert_called_with( + "/data/stats/season_qualify_results", + payload={ + "season_id": season_id, + "car_class_id": car_class_id, + "race_week_num": race_week_num, + "division": 0, + }, + ) + @patch.object(irDataClient, "_get_chunks") @patch.object(irDataClient, "_get_resource") def test_stats_world_records(self, mock_get_resource, mock_get_chunks):