From 0c8c61c4c466ce009c923145d356a5b5a7dae023 Mon Sep 17 00:00:00 2001 From: sandyr Date: Mon, 22 Jan 2024 12:42:02 +0000 Subject: [PATCH] test updates since last_update field became auto --- tests/api/test_study.py | 47 +++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/tests/api/test_study.py b/tests/api/test_study.py index 3cbf0c4ab..0f3886d16 100644 --- a/tests/api/test_study.py +++ b/tests/api/test_study.py @@ -70,13 +70,13 @@ def test_public(self, client, study, study_private): assert d['attributes']['accession'] == "MGYS00001234" def test_csv(self, client, studies): - url = reverse("emgapi_v1:studies-list", kwargs={'format': 'csv'}) + url = reverse("emgapi_v1:studies-list", kwargs={'format': 'csv', 'ordering': 'last_update'}) response = client.get(url) assert response.status_code == status.HTTP_200_OK assert response.get('Content-Disposition') == 'attachment; filename="Study.csv"' content = b''.join(response.streaming_content).decode('utf-8') - expected_header = ",".join([ + expected_header = [ "\"accession\"", "\"analyses\"", "\"bioproject\"", @@ -93,29 +93,34 @@ def test_csv(self, client, studies): "\"study_abstract\"", "\"study_name\"", "\"url\"" - ]) - first_row = ",".join([ - "\"MGYS00000001\"", - "\"\"", - "\"PRJDB0001\"", - "\"Centre Name\"", - "\"HARVESTED\"", - "\"\"", + ] + first_row = [ + "MGYS00000001", + "", + "PRJDB0001", + "Centre Name", + "HARVESTED", + "", "False", - "\"1970-01-01T00:00:00\"", - "\"\"", - "\"\"", - "\"\"", - "\"\"", - "\"SRP0001\"", - "\"\"", - "\"Example study name 1\"", - "\"http://testserver/v1/studies/MGYS00000001.csv\"" - ]) + None, + "", + "", + "", + "", + "SRP0001", + "", + "Example study name 1", + "http://testserver/v1/studies/MGYS00000001.csv" + ] rows = content.splitlines() assert len(rows) == 50 assert expected_header == rows[0] - assert first_row == rows[1] + first_row_response = rows[1].split(',') + assert len(first_row_response) == len(first_row) + for response_element, expected_element in zip(first_row_response, first_row): + if expected_element is not None: + assert response_element == expected_element +