From a5a6d6a78da148df9d66e40bb2ffe8c70ef0d5da Mon Sep 17 00:00:00 2001 From: Monkey Do Date: Fri, 26 Apr 2024 15:44:22 +0200 Subject: [PATCH 1/2] Fix delay in test for for deletion page Following from the partial fix added in #2839 --- .../tests/integration/test_settings_views.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/listenbrainz/tests/integration/test_settings_views.py b/listenbrainz/tests/integration/test_settings_views.py index 40c688ae1f..3fcd8ad98c 100644 --- a/listenbrainz/tests/integration/test_settings_views.py +++ b/listenbrainz/tests/integration/test_settings_views.py @@ -127,7 +127,18 @@ def test_delete_listens(self): 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'])) - self.assert200(resp) - self.assertEqual(resp.json['latest_import'], 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 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'])) + self.assert200(resp) + if json.loads(resp.data)['latest_import'] == 0: + continue + else: + ok = True + + if not ok: + self.assertEqual(resp.json['latest_import'], 0) \ No newline at end of file From 6b99008157bef543bf2560caabfb6b74e4d3616c Mon Sep 17 00:00:00 2001 From: Monkey Do Date: Fri, 26 Apr 2024 15:47:12 +0200 Subject: [PATCH 2/2] Pep --- 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 3fcd8ad98c..d361530e81 100644 --- a/listenbrainz/tests/integration/test_settings_views.py +++ b/listenbrainz/tests/integration/test_settings_views.py @@ -141,4 +141,4 @@ def test_delete_listens(self): ok = True if not ok: - self.assertEqual(resp.json['latest_import'], 0) \ No newline at end of file + self.assertEqual(resp.json['latest_import'], 0)