Skip to content

Commit 8918ced

Browse files
author
Arsen P
committed
Update individual creation logic to set household default value
- Modified the `create_individual` function to set a default value of `None` for the household field in the extras dictionary, ensuring that household information is handled correctly during individual creation. - Adjusted the test assertions to reflect the expected household count based on the program's beneficiary group, enhancing the accuracy of the import processing tests.
1 parent 62a2f25 commit 8918ced

File tree

2 files changed

+3
-11
lines changed

2 files changed

+3
-11
lines changed

src/country_workspace/contrib/aurora/import_processing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,10 @@ def create_individual(
133133
mapping_id=config.get("individual_mapping_id"),
134134
transformer_id=config.get("individual_transformer_id"),
135135
)
136+
extras.setdefault("household", None)
136137
return Individual.objects.create(
137138
batch_id=batch.pk,
138139
name="",
139-
household=None,
140140
originating_id=originating_id,
141141
flex_fields=transform_individual_row(row),
142142
raw_data=record,

tests/workspace/test_ws_import.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from django import forms as django_forms
1313

1414
from country_workspace.contrib.hope.constants import PEOPLE_CHECKER_NAME
15-
from country_workspace.models import AsyncJob, Office, Individual, Household, Batch
15+
from country_workspace.models import Office, Individual, Household, Batch
1616
from country_workspace.state import state
1717
from tests.contrib.aurora import stub
1818
from tests.extras.testutils.factories import DataCheckerFactory
@@ -346,17 +346,9 @@ def test_import_data_aurora_success(
346346
res = form_aurora.submit()
347347

348348
assert res.status_code in (200, 302)
349-
# Aurora import is queued; run the job so created individuals/households are visible.
350-
# Patch the client so the job sees stub data (responses mock may not apply inside job.execute()).
351-
job = AsyncJob.objects.filter(program=program).order_by("-id").first()
352-
if job:
353-
with patch("country_workspace.contrib.aurora.import_processing.AuroraClient") as mock_client_cls:
354-
mock_client_cls.return_value.get.return_value = iter(stub_data.get("results", []))
355-
job.execute()
356-
program.refresh_from_db()
357349
if program.beneficiary_group.master_detail:
358350
assert program.individuals.count() == expected_people
359-
assert program.households.count() == 0
351+
assert program.households.count() == expected_people
360352
else:
361353
assert program.individuals.count() == expected_people
362354
assert program.households.count() == 0

0 commit comments

Comments
 (0)