Skip to content

Commit 72c77d8

Browse files
dwillisclaude
andcommitted
fix: update README Summary example; add Series happy-path test
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 6f588d8 commit 72c77d8

2 files changed

Lines changed: 46 additions & 2 deletions

File tree

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,13 @@ For a summary of live matches, create an instance of the `Summary` class:
2222

2323
```python
2424
>>> from espncricinfo.summary import Summary
25+
>>> from espncricinfo.match import Match
2526
>>> s = Summary()
26-
>>> s.match_ids
27-
['68079', '68209', '68081', '61375', '65429']
27+
>>> s.matches
28+
[(1478874, 1478914), ...]
29+
>>> for series_id, match_id in s.matches:
30+
... m = Match(match_id, series_id)
31+
... print(m.description)
2832
```
2933

3034
For individual matches, pass in both the match ID and series ID. These can be discovered from `get_recent_matches()`, or read from a match page URL (the two numeric IDs in the URL path):

tests/test_series.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,43 @@ def test_series_not_found_raises_no_series_error(self):
1919
return_value=_mock_response(status_code=404)):
2020
with self.assertRaises(NoSeriesError):
2121
Series(9999999)
22+
23+
24+
def _mock_series_response():
25+
"""A minimal valid series JSON."""
26+
return _mock_response(status_code=200, json_data={
27+
"name": "India Women in Australia",
28+
"shortName": "IND-W in AUS",
29+
"abbreviation": "IND-W v AUS-W",
30+
"slug": "india-women-in-australia-2025-26",
31+
"isTournament": False,
32+
"links": [{"href": "https://www.espncricinfo.com/series/india-women-in-australia-2025-26-1478874"}],
33+
})
34+
35+
36+
def _mock_seasons_response():
37+
return _mock_response(status_code=200, json_data={"items": [
38+
{"$ref": "http://core.espnuk.org/v2/sports/cricket/leagues/1478874/seasons/2025"}
39+
]})
40+
41+
42+
def _mock_events_response():
43+
return _mock_response(status_code=200, json_data={"items": []})
44+
45+
46+
class TestSeriesHappyPath(unittest.TestCase):
47+
48+
def test_series_name_populated(self):
49+
def side_effect(url, headers=None):
50+
if url.endswith("/seasons"):
51+
return _mock_seasons_response()
52+
elif url.endswith("/events"):
53+
return _mock_events_response()
54+
else:
55+
return _mock_series_response()
56+
57+
with patch("espncricinfo.series.requests.get", side_effect=side_effect):
58+
s = Series(1478874)
59+
self.assertEqual(s.name, "India Women in Australia")
60+
self.assertEqual(s.short_name, "IND-W in AUS")
61+
self.assertFalse(s.is_tournament)

0 commit comments

Comments
 (0)