fix: preserve complete source snapshots and exports
This commit is contained in:
@@ -181,6 +181,49 @@ class CheckoSectionSnapshotTests(TestCase):
|
||||
assert artifact.metadata["quota_skipped"] == 2
|
||||
assert before == [self.existing(org) for org in self.orgs]
|
||||
|
||||
def test_overlapping_provider_pages_preserve_previous_four_records(self):
|
||||
from copy import deepcopy
|
||||
|
||||
from apps.parsers.checko_sections import collect_checko_section
|
||||
|
||||
from tests.apps.parsers.test_checko_sections import client_with, fixture
|
||||
|
||||
org = self.orgs[0]
|
||||
OrganizationSourceIngestionService.save_records(
|
||||
source=SOURCE,
|
||||
load_batch=1,
|
||||
records=[record(org, str(n)) for n in range(4)],
|
||||
)
|
||||
before = self.existing(org)
|
||||
first, second = fixture("messages-page-1.json"), fixture("messages-page-2.json")
|
||||
shared = deepcopy(first["data"]["Записи"][0])
|
||||
first["data"]["Записи"].append(dict(shared, GUID="other-first"))
|
||||
second["data"]["Записи"].insert(0, shared)
|
||||
for response in (first, second):
|
||||
response["company"].update({"ИНН": org.inn, "ОГРН": org.ogrn})
|
||||
response["data"]["ЗапВсего"] = 4
|
||||
for message in response["data"]["Записи"]:
|
||||
message["Публикатор"] = org.ogrn
|
||||
message["Участники"] = [org.inn]
|
||||
rows = collect_checko_section(
|
||||
client_with(first, second),
|
||||
organization=org,
|
||||
source=SOURCE,
|
||||
)
|
||||
(artifact, _), _ = self.run_refresh(rows=[rows, [record(self.orgs[1])]])
|
||||
assert self.existing(org) == before
|
||||
assert artifact.metadata["organizations_failed"] == 1
|
||||
assert artifact.metadata["completeness"] == "partial"
|
||||
assert not ParserStagedRecord.objects.filter(
|
||||
artifact=artifact, organization=org
|
||||
).exists()
|
||||
attempt = CheckoCollectionAttempt.objects.get(organization=org, source=SOURCE)
|
||||
assert attempt.status == attempt.Status.FAILED
|
||||
assert (
|
||||
claim_monthly_collection(organization_id=str(org.uid), source=SOURCE)
|
||||
is None
|
||||
)
|
||||
|
||||
def test_publication_failure_rolls_back_records(self):
|
||||
self.seed(self.orgs[0])
|
||||
before = self.existing(self.orgs[0])
|
||||
|
||||
Reference in New Issue
Block a user