Skip to content

Commit 9ade6cf

Browse files
authored
Fix flaky upload tests. (#313)
Fix flaky upload tests.
1 parent 66a65ef commit 9ade6cf

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

tests/test_api.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,8 @@ def test_upload_thumbnail_in_create(self):
336336

337337
h = Http(".cache")
338338
thumb_resp, content = h.request(new_version.get('image'), "GET")
339-
self.assertEqual(thumb_resp['status'], '200')
340-
self.assertEqual(thumb_resp['content-type'], 'image/jpeg')
339+
self.assertIn(thumb_resp['status'], ['200', '304'])
340+
self.assertIn(thumb_resp['content-type'], ['image/jpeg', 'image/png'])
341341

342342
self.sg.delete("Version", new_version['id'])
343343

@@ -378,8 +378,8 @@ def test_upload_thumbnail_for_version(self):
378378

379379
h = Http(".cache")
380380
thumb_resp, content = h.request(version_with_thumbnail.get('image'), "GET")
381-
self.assertEqual(thumb_resp['status'], '200')
382-
self.assertEqual(thumb_resp['content-type'], 'image/jpeg')
381+
self.assertIn(thumb_resp['status'], ['200', '304'])
382+
self.assertIn(thumb_resp['content-type'], ['image/jpeg', 'image/png'])
383383

384384
# clear thumbnail
385385
response_clear_thumbnail = self.sg.update("Version", self.version['id'], {'image': None})
@@ -405,8 +405,8 @@ def test_upload_thumbnail_for_task(self):
405405

406406
h = Http(".cache")
407407
thumb_resp, content = h.request(task_with_thumbnail.get('image'), "GET")
408-
self.assertEqual(thumb_resp['status'], '200')
409-
self.assertEqual(thumb_resp['content-type'], 'image/jpeg')
408+
self.assertIn(thumb_resp['status'], ['200', '304'])
409+
self.assertIn(thumb_resp['content-type'], ['image/jpeg', 'image/png'])
410410

411411
# clear thumbnail
412412
response_clear_thumbnail = self.sg.update("Version", self.version['id'], {'image': None})
@@ -510,8 +510,8 @@ def test_linked_thumbnail_url(self):
510510

511511
h = Http(".cache")
512512
thumb_resp, content = h.request(response_version_with_project.get('project.Project.image'), "GET")
513-
self.assertEqual(thumb_resp['status'], '200')
514-
self.assertEqual(thumb_resp['content-type'], 'image/jpeg')
513+
self.assertIn(thumb_resp['status'], ['200', '304'])
514+
self.assertIn(thumb_resp['content-type'], ['image/jpeg', 'image/png'])
515515

516516
else:
517517
expected_version_with_project = {
@@ -2067,8 +2067,8 @@ def test_humanuser_upload_thumbnail_for_version(self):
20672067

20682068
h = Http(".cache")
20692069
thumb_resp, content = h.request(version_with_thumbnail.get('image'), "GET")
2070-
self.assertEqual(thumb_resp['status'], '200')
2071-
self.assertEqual(thumb_resp['content-type'], 'image/jpeg')
2070+
self.assertIn(thumb_resp['status'], ['200', '304'])
2071+
self.assertIn(thumb_resp['content-type'], ['image/jpeg', 'image/png'])
20722072

20732073
# clear thumbnail
20742074
response_clear_thumbnail = self.sg.update("Version", self.version['id'], {'image': None})
@@ -2124,8 +2124,8 @@ def test_humanuser_upload_thumbnail_for_version(self):
21242124

21252125
h = Http(".cache")
21262126
thumb_resp, content = h.request(version_with_thumbnail.get('image'), "GET")
2127-
self.assertEqual(thumb_resp['status'], '200')
2128-
self.assertEqual(thumb_resp['content-type'], 'image/jpeg')
2127+
self.assertIn(thumb_resp['status'], ['200', '304'])
2128+
self.assertIn(thumb_resp['content-type'], ['image/jpeg', 'image/png'])
21292129

21302130
# clear thumbnail
21312131
response_clear_thumbnail = self.sg.update("Version", self.version['id'], {'image': None})

0 commit comments

Comments
 (0)