fix: collect enabled sources weekly including Checko
This commit is contained in:
@@ -6,7 +6,7 @@ from tempfile import TemporaryDirectory
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
import pytest
|
||||
from apps.parsers.checko_collection import claim_monthly_collection, finish_collection
|
||||
from apps.parsers.checko_collection import claim_weekly_collection, finish_collection
|
||||
from apps.parsers.models import (
|
||||
CheckoCollectionAttempt,
|
||||
ParserSourceArtifact,
|
||||
@@ -96,7 +96,7 @@ class CheckoSectionSnapshotTests(TestCase):
|
||||
def test_claimed_organization_keeps_previous_records(self):
|
||||
self.seed(self.orgs[0])
|
||||
before = self.existing(self.orgs[0])
|
||||
claim_monthly_collection(organization_id=str(self.orgs[0].uid), source=SOURCE)
|
||||
claim_weekly_collection(organization_id=str(self.orgs[0].uid), source=SOURCE)
|
||||
(artifact, result), collector = self.run_refresh(rows=[[record(self.orgs[1])]])
|
||||
assert self.existing(self.orgs[0]) == before
|
||||
assert collector.call_count == 1
|
||||
@@ -134,7 +134,7 @@ class CheckoSectionSnapshotTests(TestCase):
|
||||
for org in self.orgs:
|
||||
self.seed(org)
|
||||
before = self.existing(self.orgs[1])
|
||||
claim_monthly_collection(organization_id=str(self.orgs[1].uid), source=SOURCE)
|
||||
claim_weekly_collection(organization_id=str(self.orgs[1].uid), source=SOURCE)
|
||||
self.run_refresh(rows=[[]])
|
||||
assert not self.existing(self.orgs[0])
|
||||
assert self.existing(self.orgs[1]) == before
|
||||
@@ -163,7 +163,7 @@ class CheckoSectionSnapshotTests(TestCase):
|
||||
)
|
||||
assert attempt.status == attempt.Status.FAILED
|
||||
assert (
|
||||
claim_monthly_collection(
|
||||
claim_weekly_collection(
|
||||
organization_id=str(self.orgs[0].uid), source=SOURCE
|
||||
)
|
||||
is None
|
||||
@@ -172,7 +172,7 @@ class CheckoSectionSnapshotTests(TestCase):
|
||||
def test_no_completed_scope_rejects_without_publication(self):
|
||||
for org in self.orgs:
|
||||
self.seed(org)
|
||||
claim_monthly_collection(organization_id=str(org.uid), source=SOURCE)
|
||||
claim_weekly_collection(organization_id=str(org.uid), source=SOURCE)
|
||||
before = [self.existing(org) for org in self.orgs]
|
||||
with pytest.raises(SnapshotValidationError, match="no_completed_organizations"):
|
||||
self.run_refresh()
|
||||
@@ -220,7 +220,7 @@ class CheckoSectionSnapshotTests(TestCase):
|
||||
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)
|
||||
claim_weekly_collection(organization_id=str(org.uid), source=SOURCE)
|
||||
is None
|
||||
)
|
||||
|
||||
@@ -246,7 +246,7 @@ class CheckoSectionSnapshotTests(TestCase):
|
||||
before = [self.existing(org)[0][0] for org in self.orgs]
|
||||
# Advance the calendar; never delete or reset a monthly claim.
|
||||
with patch(
|
||||
"apps.parsers.checko_collection.collection_period_month",
|
||||
"apps.parsers.checko_collection.collection_period_week",
|
||||
return_value=date(2026, 11, 1),
|
||||
):
|
||||
self.run_refresh(load_batch=2)
|
||||
@@ -257,13 +257,13 @@ class CheckoSectionSnapshotTests(TestCase):
|
||||
CheckoCollectionAttempt.Source.values
|
||||
)
|
||||
for source in adapter().CHECKO_SECTIONS:
|
||||
attempt = claim_monthly_collection(
|
||||
attempt = claim_weekly_collection(
|
||||
organization_id=str(self.orgs[0].uid), source=source
|
||||
)
|
||||
assert attempt is not None
|
||||
finish_collection(attempt, records_count=0, error="fixture")
|
||||
assert (
|
||||
claim_monthly_collection(
|
||||
claim_weekly_collection(
|
||||
organization_id=str(self.orgs[0].uid), source=source
|
||||
)
|
||||
is None
|
||||
@@ -311,7 +311,7 @@ def test_concurrent_monthly_claim_one_winner():
|
||||
|
||||
def claim():
|
||||
return (
|
||||
claim_monthly_collection(organization_id=str(org.uid), source=SOURCE)
|
||||
claim_weekly_collection(organization_id=str(org.uid), source=SOURCE)
|
||||
is not None
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user