Skip to content

Commit 1898aa9

Browse files
committed
fix(test): consume Django streaming_content for NDJSON responses
1 parent e7e9fc6 commit 1898aa9

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

backend/access/tests/test_access_list.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ def test_user_access_list_stream_matches_paginated_list(self):
121121
)
122122
self.assertEqual(response_stream.status_code, 200)
123123
self.assertEqual(response_stream.headers["Content-Type"], "application/x-ndjson")
124-
rows = [json.loads(line) for line in response_stream.content.decode().splitlines() if line.strip()]
124+
text = b"".join(response_stream.streaming_content).decode()
125+
rows = [json.loads(line) for line in text.splitlines() if line.strip()]
125126
self.assertEqual(rows, response_list.json()["results"])
126127

127128
def test_entity_access_list_stream_matches_paginated_list(self):
@@ -136,5 +137,6 @@ def test_entity_access_list_stream_matches_paginated_list(self):
136137
)
137138
self.assertEqual(response_stream.status_code, 200)
138139
self.assertEqual(response_stream.headers["Content-Type"], "application/x-ndjson")
139-
rows = [json.loads(line) for line in response_stream.content.decode().splitlines() if line.strip()]
140+
text = b"".join(response_stream.streaming_content).decode()
141+
rows = [json.loads(line) for line in text.splitlines() if line.strip()]
140142
self.assertEqual(rows, response_list.json()["results"])

backend/entries/tests/test_entity_list_view.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ def test_get_entities_stream_matches_paginated_list(self):
5757
response_stream = self.client.get(reverse("entity_list_stream"), **self.headers_admin)
5858
self.assertEqual(response_stream.status_code, 200)
5959
self.assertEqual(response_stream.headers["Content-Type"], "application/x-ndjson")
60-
rows = [json.loads(line) for line in response_stream.content.decode().splitlines() if line.strip()]
60+
text = b"".join(response_stream.streaming_content).decode()
61+
rows = [json.loads(line) for line in text.splitlines() if line.strip()]
6162
self.assertEqual(rows, response_list.json()["results"])
6263

6364

0 commit comments

Comments
 (0)