Align frontend API contracts
This commit is contained in:
@@ -202,7 +202,7 @@ class ParsersViewSetTest(APITestCase):
|
||||
)
|
||||
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
rows = response.data["data"]
|
||||
rows = response.data["results"]
|
||||
self.assertEqual(len(rows), 1)
|
||||
self.assertEqual(rows[0]["id"], first_log.id)
|
||||
self.assertEqual(rows[0]["organizations_count"], 2)
|
||||
@@ -228,6 +228,23 @@ class ParsersViewSetTest(APITestCase):
|
||||
self.assertIn("organizations_count", content)
|
||||
self.assertIn("333", content)
|
||||
|
||||
def test_system_logs_support_search_by_source_label(self):
|
||||
ParserLoadLogFactory(
|
||||
source="fns_reports",
|
||||
batch_id=909,
|
||||
status="success",
|
||||
)
|
||||
|
||||
self.client.force_authenticate(self.admin)
|
||||
response = self.client.get(
|
||||
reverse("api_v1:system:parser-logs-list"),
|
||||
{"search": "финансово"},
|
||||
)
|
||||
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
self.assertEqual(len(response.data["results"]), 1)
|
||||
self.assertEqual(response.data["results"][0]["source"], "financial-indicators")
|
||||
|
||||
def test_fns_upload_invalid_filename(self):
|
||||
self.client.force_authenticate(self.admin)
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
@@ -277,3 +294,46 @@ class ParsersViewSetTest(APITestCase):
|
||||
url, {"files": [upload]}, format="multipart"
|
||||
)
|
||||
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
|
||||
|
||||
def test_fns_upload_accepts_single_file_payload(self):
|
||||
self.client.force_authenticate(self.admin)
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
watch_dir = os.path.join(tmpdir, "watch")
|
||||
processed_dir = os.path.join(tmpdir, "processed")
|
||||
failed_dir = os.path.join(tmpdir, "failed")
|
||||
content = _build_fns_excel_bytes()
|
||||
upload = SimpleUploadedFile(
|
||||
f"fin_{_digits(5)}_{_digits(13)}.xlsx",
|
||||
content,
|
||||
content_type=(
|
||||
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
||||
),
|
||||
)
|
||||
with self.settings(
|
||||
FNS_WATCH_DIRECTORY=watch_dir,
|
||||
FNS_PROCESSED_DIRECTORY=processed_dir,
|
||||
FNS_FAILED_DIRECTORY=failed_dir,
|
||||
):
|
||||
url = reverse("api_v1:fns:fns-upload")
|
||||
response = self.client.post(url, {"file": upload}, format="multipart")
|
||||
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
self.assertEqual(response.data["success"], True)
|
||||
self.assertIn("message", response.data)
|
||||
|
||||
def test_parsing_settings_get_and_patch(self):
|
||||
self.client.force_authenticate(self.admin)
|
||||
url = reverse("api_v1:parsing:parsing-settings")
|
||||
|
||||
initial = self.client.get(url)
|
||||
self.assertEqual(initial.status_code, status.HTTP_200_OK)
|
||||
self.assertEqual(initial.data["planned_inspections"], "monthly")
|
||||
|
||||
updated = self.client.patch(
|
||||
url,
|
||||
{"planned_inspections": "weekly"},
|
||||
format="json",
|
||||
)
|
||||
|
||||
self.assertEqual(updated.status_code, status.HTTP_200_OK)
|
||||
self.assertEqual(updated.data["planned_inspections"], "weekly")
|
||||
|
||||
Reference in New Issue
Block a user