55from test_fixtures .fixtures_households import (
66 MOCK_HOUSEHOLD_MINIMAL ,
77 MOCK_UK_HOUSEHOLD_CREATE ,
8+ MOCK_US_FULL_MULTI_GROUP_HOUSEHOLD_CREATE ,
89 MOCK_US_HOUSEHOLD_CREATE ,
910 MOCK_US_HOUSEHOLD_CREATE_LEGACY ,
1011 MOCK_US_MULTI_GROUP_HOUSEHOLD_CREATE ,
@@ -62,14 +63,20 @@ def test_create_household_minimal(client):
6263
6364
6465def test_create_household_round_trips_multiple_entity_groups (client ):
65- """Stored household CRUD preserves multiple marital units."""
66- response = client .post ("/households" , json = MOCK_US_MULTI_GROUP_HOUSEHOLD_CREATE )
66+ """Stored household CRUD preserves multiple rows across entity groups."""
67+ response = client .post (
68+ "/households" , json = MOCK_US_FULL_MULTI_GROUP_HOUSEHOLD_CREATE
69+ )
6770 assert response .status_code == 201
6871 data = response .json ()
69- assert len (data ["tax_unit" ]) == 1
70- assert data ["tax_unit" ][0 ]["tax_unit_id" ] == 0
72+ assert len (data ["tax_unit" ]) == 2
7173 assert len (data ["marital_unit" ]) == 2
72- assert data ["people" ][1 ]["person_marital_unit_id" ] == 1
74+ assert len (data ["family" ]) == 2
75+ assert len (data ["spm_unit" ]) == 2
76+ assert len (data ["household" ]) == 2
77+ assert data ["people" ][0 ]["person_tax_unit_id" ] == 0
78+ assert data ["people" ][1 ]["person_tax_unit_id" ] == 1
79+ assert data ["people" ][1 ]["person_household_id" ] == 1
7380
7481
7582def test_create_household_invalid_country_id (client ):
@@ -154,8 +161,8 @@ def test_create_household_requires_person_links_for_multi_group_rows(client):
154161 assert "when " in response .text
155162
156163
157- def test_create_household_rejects_multiple_tax_units (client ):
158- """Stored households support at most one tax unit ."""
164+ def test_create_household_accepts_multiple_tax_units (client ):
165+ """Stored households preserve multiple tax units when person links are present ."""
159166 payload = {
160167 ** MOCK_US_MULTI_GROUP_HOUSEHOLD_CREATE ,
161168 "tax_unit" : [
@@ -182,12 +189,14 @@ def test_create_household_rejects_multiple_tax_units(client):
182189
183190 response = client .post ("/households" , json = payload )
184191
185- assert response .status_code == 422
186- assert "tax_unit supports at most one row" in response .text
192+ assert response .status_code == 201
193+ data = response .json ()
194+ assert len (data ["tax_unit" ]) == 2
195+ assert data ["people" ][1 ]["person_tax_unit_id" ] == 1
187196
188197
189- def test_create_household_rejects_multiple_households (client ):
190- """Stored households support at most one household row ."""
198+ def test_create_household_accepts_multiple_households (client ):
199+ """Stored households preserve multiple household rows when person links are present ."""
191200 payload = {
192201 ** MOCK_US_MULTI_GROUP_HOUSEHOLD_CREATE ,
193202 "household" : [
@@ -214,8 +223,10 @@ def test_create_household_rejects_multiple_households(client):
214223
215224 response = client .post ("/households" , json = payload )
216225
217- assert response .status_code == 422
218- assert "household supports at most one row" in response .text
226+ assert response .status_code == 201
227+ data = response .json ()
228+ assert len (data ["household" ]) == 2
229+ assert data ["people" ][1 ]["person_household_id" ] == 1
219230
220231
221232# ---------------------------------------------------------------------------
0 commit comments