Skip to content

Commit

Permalink
Return the right number of artists, not one short, lol. (#2839)
Browse files Browse the repository at this point in the history
* Return the right number of artists, not one short, lol.

* maybe maybe maybe

* Make the wait time for the failing test dynamic
  • Loading branch information
mayhem committed Apr 16, 2024
1 parent e6c6027 commit f39c156
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion listenbrainz/db/lb_radio_artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def lb_radio_artist(mode: str, seed_artist: str, max_similar_artists: int, num_r
FROM randomize
JOIN mapping.mb_artist_metadata_cache
ON artist_mbid = similar_artist_mbid
WHERE rownum < {num_recordings_per_artist}
WHERE rownum <= {num_recordings_per_artist}
""").format(
seed_artist_mbid=Literal(uuid.UUID(seed_artist)),
similar_artist_limit=Literal(100),
Expand Down
22 changes: 15 additions & 7 deletions listenbrainz/tests/integration/test_settings_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,21 @@ def test_delete_listens(self):
self.assertEquals(task.user_id, self.user["id"])
self.assertEquals(task.task, "delete_listens")

# wait for background tasks to be processed
time.sleep(5)

# check that listens have been successfully deleted
resp = self.client.get(self.custom_url_for('api_v1.get_listen_count', user_name=self.user['musicbrainz_id']))
self.assert200(resp)
self.assertEqual(json.loads(resp.data)['payload']['count'], 0)
# wait for background tasks to be processed -- max 30s allowed for the test to pass
ok = False
for i in range(30):
time.sleep(1)

# check that listens have been successfully deleted
resp = self.client.get(self.custom_url_for('api_v1.get_listen_count', user_name=self.user['musicbrainz_id']))
self.assert200(resp)
if json.loads(resp.data)['payload']['count'] == 0:
continue
else:
ok = True

if not ok:
self.assertEqual(json.loads(resp.data)['payload']['count'], 0)

# check that the latest_import timestamp has been reset too
resp = self.client.get(self.custom_url_for('api_v1.latest_import', user_name=self.user['musicbrainz_id']))
Expand Down

0 comments on commit f39c156

Please sign in to comment.