Add v2 registry uploads and source CSV exports
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import csv
|
||||
import io
|
||||
import os
|
||||
import tempfile
|
||||
@@ -99,6 +100,41 @@ class ParsersViewSetTest(APITestCase):
|
||||
)
|
||||
self.assertEqual(detail.status_code, status.HTTP_200_OK)
|
||||
|
||||
def test_v2_source_csv_download_exports_source_rows(self):
|
||||
record = IndustrialCertificateRecordFactory(
|
||||
certificate_number="CERT-CSV-1",
|
||||
organisation_name='АО "CSV"',
|
||||
inn="7701000101",
|
||||
ogrn="1027700000001",
|
||||
)
|
||||
self.client.force_authenticate(self.user)
|
||||
|
||||
response = self.client.get(
|
||||
reverse("api_v2:parser_sources:minpromtorg-certificates-download")
|
||||
)
|
||||
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
self.assertEqual(response["Content-Type"], "text/csv; charset=utf-8")
|
||||
self.assertIn(
|
||||
'attachment; filename="minpromtorg-certificates.csv"',
|
||||
response["Content-Disposition"],
|
||||
)
|
||||
rows = list(csv.DictReader(io.StringIO(response.content.decode("utf-8"))))
|
||||
self.assertEqual(len(rows), 1)
|
||||
self.assertEqual(rows[0]["id"], str(record.id))
|
||||
self.assertEqual(rows[0]["source"], ParserLoadLog.Source.INDUSTRIAL)
|
||||
self.assertEqual(rows[0]["external_id"], "CERT-CSV-1")
|
||||
self.assertEqual(rows[0]["organisation_name"], 'АО "CSV"')
|
||||
self.assertEqual(rows[0]["inn"], "7701000101")
|
||||
self.assertIn("CERT-CSV-1", rows[0]["payload"])
|
||||
|
||||
def test_v2_source_csv_download_is_not_registered_for_financial_reports(self):
|
||||
self.client.force_authenticate(self.user)
|
||||
|
||||
response = self.client.get("/api/v2/sources/fns/reports/download/")
|
||||
|
||||
self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
|
||||
|
||||
def test_manufacturers_list_and_retrieve(self):
|
||||
record = ManufacturerRecordFactory()
|
||||
second_record = ManufacturerRecordFactory()
|
||||
@@ -404,6 +440,10 @@ class ParsersViewSetTest(APITestCase):
|
||||
sources["procurements_44fz"]["result_list_url"],
|
||||
"/api/v1/parsers/results/procurements_44fz/",
|
||||
)
|
||||
self.assertEqual(
|
||||
sources["procurements_44fz"]["api_route"],
|
||||
"eis/procurements-44fz",
|
||||
)
|
||||
self.assertEqual(
|
||||
sources["procurements_223fz"]["result_list_url"],
|
||||
"/api/v1/parsers/results/procurements_223fz/",
|
||||
|
||||
Reference in New Issue
Block a user