From 9162b62a51d517bd8d25f6fc44c74a5eaff2295c Mon Sep 17 00:00:00 2001 From: Robert Kaye Date: Mon, 15 Apr 2024 16:28:07 +0200 Subject: [PATCH 1/3] Return the right number of artists, not one short, lol. --- listenbrainz/db/lb_radio_artist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/listenbrainz/db/lb_radio_artist.py b/listenbrainz/db/lb_radio_artist.py index a3fd67a39e..4ec05d1a1e 100644 --- a/listenbrainz/db/lb_radio_artist.py +++ b/listenbrainz/db/lb_radio_artist.py @@ -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), From bd78b72462d47896c71c20e53cff5a16961a9590 Mon Sep 17 00:00:00 2001 From: Robert Kaye Date: Tue, 16 Apr 2024 12:26:27 +0200 Subject: [PATCH 2/3] maybe maybe maybe --- listenbrainz/tests/integration/test_settings_views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/listenbrainz/tests/integration/test_settings_views.py b/listenbrainz/tests/integration/test_settings_views.py index 362ebf51bd..b1b98acb92 100644 --- a/listenbrainz/tests/integration/test_settings_views.py +++ b/listenbrainz/tests/integration/test_settings_views.py @@ -112,7 +112,7 @@ def test_delete_listens(self): self.assertEquals(task.task, "delete_listens") # wait for background tasks to be processed - time.sleep(5) + time.sleep(7) # 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'])) From 80b5a6d46770c72067a45203de6ab529b28ad8d6 Mon Sep 17 00:00:00 2001 From: Robert Kaye Date: Tue, 16 Apr 2024 12:38:48 +0200 Subject: [PATCH 3/3] Make the wait time for the failing test dynamic --- .../tests/integration/test_settings_views.py | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/listenbrainz/tests/integration/test_settings_views.py b/listenbrainz/tests/integration/test_settings_views.py index b1b98acb92..40c688ae1f 100644 --- a/listenbrainz/tests/integration/test_settings_views.py +++ b/listenbrainz/tests/integration/test_settings_views.py @@ -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(7) - - # 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']))