Skip to content

Commit

Permalink
test: dats as attachment
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlougheed committed Sep 30, 2024
1 parent e979cc5 commit 0715010
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions chord_metadata_service/chord/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,24 @@ def test_dats(self):
response = self.client.get("/api/datasets/does-not-exist/dats")
self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)

def test_dats_as_attachment(self):
payload = {**self.dats_valid_payload, 'dats_file': {}}

r = self.one_authz_post('/api/datasets', data=json.dumps(payload))

self.assertEqual(r.status_code, status.HTTP_201_CREATED)
dataset_id = Dataset.objects.first().identifier

response = self.client.get(f"/api/datasets/{dataset_id}/dats?attachment=true")
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertDictEqual(response.data, payload['dats_file'])
self.assertEqual(response.headers["Content-Disposition"], f"attachment; filename=\"{dataset_id}_dats.json\"")

response = self.client.get(f"/api/datasets/{dataset_id}/dats?attachment=false")
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertDictEqual(response.data, payload['dats_file'])
self.assertNotIn("Content-Disposition", response.headers)

def test_resources(self):
resource = {
"id": "NCBITaxon:2023-09-14",
Expand Down

0 comments on commit 0715010

Please sign in to comment.