Skip to content

Commit f75b244

Browse files
committed
Fix sitewide api tests
Use the expected count from the arguments of the assertSitewideStatEqual function call, and adds a total_{entity}_count check
1 parent f39f10b commit f75b244

7 files changed

+20
-12
lines changed

listenbrainz/testdata/sitewide_top_artists_db.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@
1414
],
1515
"to_ts": 1593043183,
1616
"stats_range": "all_time",
17-
"count": 2
17+
"count": 2,
18+
"total_artist_count": 123
1819
}

listenbrainz/testdata/sitewide_top_artists_db_data_for_api_test.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -301,5 +301,6 @@
301301
"artist_mbid": "12379346-99d9-4941-b4a2-f04144a39863"
302302
}
303303
],
304-
"count": 60
305-
}
304+
"count": 60,
305+
"total_artist_count": 60
306+
}

listenbrainz/testdata/sitewide_top_artists_db_data_for_api_test_month.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -301,5 +301,6 @@
301301
"artist_mbid": "78df245f-0fe0-4a21-b1d4-e79f695354fd"
302302
}
303303
],
304-
"count": 60
305-
}
304+
"count": 60,
305+
"total_artist_count": 60
306+
}

listenbrainz/testdata/sitewide_top_artists_db_data_for_api_test_too_many.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1011,5 +1011,6 @@
10111011
"artist_mbid": "218bbe3d-63cc-46bc-8e43-e56a2f6c9829"
10121012
}
10131013
],
1014-
"count": 202
1015-
}
1014+
"count": 202,
1015+
"total_artist_count": 202
1016+
}

listenbrainz/testdata/sitewide_top_artists_db_data_for_api_test_week.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1001,5 +1001,6 @@
10011001
"artist_mbid": "a2c1ed01-991f-4a9d-81e0-9b04c8df1c80"
10021002
}
10031003
],
1004-
"count": 200
1005-
}
1004+
"count": 200,
1005+
"total_artist_count": 200
1006+
}

listenbrainz/testdata/sitewide_top_artists_db_data_for_api_test_year.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -301,5 +301,6 @@
301301
"artist_mbid": "a63d3de8-9c39-4320-8199-784df3f4c74c"
302302
}
303303
],
304-
"count": 60
305-
}
304+
"count": 60,
305+
"total_artist_count": 60
306+
}

listenbrainz/tests/integration/test_stats_api.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,9 @@ def assertSitewideStatEqual(self, sent, response, entity, stats_range, count, of
245245

246246
received = orjson.loads(response.data)['payload']
247247

248-
self.assertEqual(sent['count'], received['count'])
248+
singular_entity = entity[:-1] if entity.endswith('s') else entity
249+
self.assertEqual(sent[f'total_{singular_entity}_count'], received[f'total_{singular_entity}_count'])
250+
self.assertEqual(count, received['count'])
249251
self.assertEqual(sent['from_ts'], received['from_ts'])
250252
self.assertEqual(sent['to_ts'], received['to_ts'])
251253
self.assertEqual(stats_range, received['range'])

0 commit comments

Comments
 (0)