Fix admin API gaps for users, exchange checks, and parser logs
This commit is contained in:
@@ -179,6 +179,55 @@ class ParsersViewSetTest(APITestCase):
|
||||
)
|
||||
self.assertEqual(proxy_detail.status_code, status.HTTP_200_OK)
|
||||
|
||||
def test_system_logs_support_search_and_organizations_count(self):
|
||||
first_log = ParserLoadLogFactory(
|
||||
source="manufactures",
|
||||
batch_id=101,
|
||||
status="success",
|
||||
error_message="ok",
|
||||
)
|
||||
ParserLoadLogFactory(
|
||||
source="inspections",
|
||||
batch_id=202,
|
||||
status="failed",
|
||||
error_message="timeout",
|
||||
)
|
||||
ManufacturerRecordFactory(load_batch=101, inn="7701000001")
|
||||
ManufacturerRecordFactory(load_batch=101, inn="7701000002")
|
||||
|
||||
self.client.force_authenticate(self.admin)
|
||||
response = self.client.get(
|
||||
reverse("api_v1:system:parser-logs-list"),
|
||||
{"search": "101"},
|
||||
)
|
||||
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
rows = response.data["data"]
|
||||
self.assertEqual(len(rows), 1)
|
||||
self.assertEqual(rows[0]["id"], first_log.id)
|
||||
self.assertEqual(rows[0]["organizations_count"], 2)
|
||||
|
||||
def test_system_logs_export_returns_csv(self):
|
||||
ParserLoadLogFactory(
|
||||
source="manufactures",
|
||||
batch_id=333,
|
||||
status="success",
|
||||
records_count=4,
|
||||
)
|
||||
ManufacturerRecordFactory(load_batch=333, inn="7701000001")
|
||||
|
||||
self.client.force_authenticate(self.admin)
|
||||
response = self.client.get(
|
||||
reverse("api_v1:system:parser-logs-export"),
|
||||
{"search": "333"},
|
||||
)
|
||||
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
self.assertEqual(response["Content-Type"], "text/csv; charset=utf-8")
|
||||
content = response.content.decode("utf-8")
|
||||
self.assertIn("organizations_count", content)
|
||||
self.assertIn("333", content)
|
||||
|
||||
def test_fns_upload_invalid_filename(self):
|
||||
self.client.force_authenticate(self.admin)
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
|
||||
Reference in New Issue
Block a user