From b9a110d974f66baa003c6d3a69ee717a800bc333 Mon Sep 17 00:00:00 2001 From: Norberto Moreno Velez Date: Wed, 25 Oct 2023 18:24:22 -0500 Subject: [PATCH] Fix flaky upload tests. --- tests/test_api.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/test_api.py b/tests/test_api.py index cf4b153dc..be3201fd6 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -336,8 +336,8 @@ def test_upload_thumbnail_in_create(self): h = Http(".cache") thumb_resp, content = h.request(new_version.get('image'), "GET") - self.assertEqual(thumb_resp['status'], '200') - self.assertEqual(thumb_resp['content-type'], 'image/jpeg') + self.assertIn(thumb_resp['status'], ['200', '304']) + self.assertIn(thumb_resp['content-type'], ['image/jpeg', 'image/png']) self.sg.delete("Version", new_version['id']) @@ -378,8 +378,8 @@ def test_upload_thumbnail_for_version(self): h = Http(".cache") thumb_resp, content = h.request(version_with_thumbnail.get('image'), "GET") - self.assertEqual(thumb_resp['status'], '200') - self.assertEqual(thumb_resp['content-type'], 'image/jpeg') + self.assertIn(thumb_resp['status'], ['200', '304']) + self.assertIn(thumb_resp['content-type'], ['image/jpeg', 'image/png']) # clear thumbnail response_clear_thumbnail = self.sg.update("Version", self.version['id'], {'image': None}) @@ -405,8 +405,8 @@ def test_upload_thumbnail_for_task(self): h = Http(".cache") thumb_resp, content = h.request(task_with_thumbnail.get('image'), "GET") - self.assertEqual(thumb_resp['status'], '200') - self.assertEqual(thumb_resp['content-type'], 'image/jpeg') + self.assertIn(thumb_resp['status'], ['200', '304']) + self.assertIn(thumb_resp['content-type'], ['image/jpeg', 'image/png']) # clear thumbnail response_clear_thumbnail = self.sg.update("Version", self.version['id'], {'image': None}) @@ -510,8 +510,8 @@ def test_linked_thumbnail_url(self): h = Http(".cache") thumb_resp, content = h.request(response_version_with_project.get('project.Project.image'), "GET") - self.assertEqual(thumb_resp['status'], '200') - self.assertEqual(thumb_resp['content-type'], 'image/jpeg') + self.assertIn(thumb_resp['status'], ['200', '304']) + self.assertIn(thumb_resp['content-type'], ['image/jpeg', 'image/png']) else: expected_version_with_project = { @@ -2067,8 +2067,8 @@ def test_humanuser_upload_thumbnail_for_version(self): h = Http(".cache") thumb_resp, content = h.request(version_with_thumbnail.get('image'), "GET") - self.assertEqual(thumb_resp['status'], '200') - self.assertEqual(thumb_resp['content-type'], 'image/jpeg') + self.assertIn(thumb_resp['status'], ['200', '304']) + self.assertIn(thumb_resp['content-type'], ['image/jpeg', 'image/png']) # clear thumbnail response_clear_thumbnail = self.sg.update("Version", self.version['id'], {'image': None}) @@ -2124,8 +2124,8 @@ def test_humanuser_upload_thumbnail_for_version(self): h = Http(".cache") thumb_resp, content = h.request(version_with_thumbnail.get('image'), "GET") - self.assertEqual(thumb_resp['status'], '200') - self.assertEqual(thumb_resp['content-type'], 'image/jpeg') + self.assertIn(thumb_resp['status'], ['200', '304']) + self.assertIn(thumb_resp['content-type'], ['image/jpeg', 'image/png']) # clear thumbnail response_clear_thumbnail = self.sg.update("Version", self.version['id'], {'image': None})