Add organizations v2 API and registry enrichment
This commit is contained in:
@@ -14,6 +14,7 @@ from apps.parsers.clients.minpromtorg.schemas import (
|
||||
from apps.parsers.clients.proverki.schemas import Inspection
|
||||
from apps.parsers.clients.zakupki.schemas import Procurement
|
||||
from apps.parsers.models import (
|
||||
GenericParserRecord,
|
||||
IndustrialCertificateRecord,
|
||||
IndustrialProductRecord,
|
||||
InspectionRecord,
|
||||
@@ -23,6 +24,7 @@ from apps.parsers.models import (
|
||||
Proxy,
|
||||
)
|
||||
from apps.parsers.services import (
|
||||
GenericParserRecordService,
|
||||
IndustrialCertificateService,
|
||||
IndustrialProductService,
|
||||
InspectionService,
|
||||
@@ -214,6 +216,32 @@ class ProxyServiceTest(TestCase):
|
||||
self.assertEqual(result, [manual_ru.address])
|
||||
|
||||
|
||||
class GenericParserRecordServiceTest(TestCase):
|
||||
def test_conflict_retry_does_not_use_per_row_get_or_create(self):
|
||||
GenericParserRecord.objects.create(
|
||||
load_batch=1,
|
||||
source=ParserLoadLog.Source.CONTRACTS,
|
||||
external_id="existing",
|
||||
)
|
||||
instance = GenericParserRecord(
|
||||
load_batch=2,
|
||||
source=ParserLoadLog.Source.CONTRACTS,
|
||||
external_id="existing",
|
||||
)
|
||||
|
||||
with patch(
|
||||
"django.db.models.query.QuerySet.get_or_create",
|
||||
side_effect=AssertionError("per-row get_or_create must not be used"),
|
||||
):
|
||||
created = GenericParserRecordService._create_with_exact_count(
|
||||
[instance],
|
||||
unique_fields=["source", "external_id"],
|
||||
chunk_size=500,
|
||||
)
|
||||
|
||||
self.assertEqual(created, 0)
|
||||
|
||||
|
||||
class ProxyToolsSyncServiceTest(TestCase):
|
||||
"""Tests for ProxyToolsSyncService."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user