@@ -110,6 +110,15 @@ def validate_instances(
110110 + instance ["livelihood_strategy" ][2 :] # strategy_type, season, product_id, additional_identifier
111111 + [instance ["wealth_group" ][3 ]] # full_name
112112 )
113+ elif model_name == "WealthGroupCharacteristicValue" :
114+ instance ["natural_key" ] = instance ["wealth_group" ][
115+ :3 # livelihood_zone, reference_year_end_date, wealth_group_category
116+ ] + [
117+ instance ["wealth_characteristic_id" ],
118+ instance ["reference_type" ],
119+ instance ["product_id" ] or "" , # Natural key components must be "" rather than None
120+ instance ["wealth_group" ][3 ], # full_name
121+ ]
113122 # The natural key is a list of strings, or possibly numbers, so validate that here to avoid confusing
114123 # error messages later.
115124 if "natural_key" not in instance :
@@ -145,7 +154,7 @@ def validate_instances(
145154 if column not in instance :
146155 error = f"Missing mandatory field { field .name } for { record_reference } "
147156 model_errors .append (error )
148- elif not instance [column ]:
157+ elif not instance [column ] and not instance [ column ] == 0 :
149158 error = f"Missing value for mandatory field { column } for { record_reference } "
150159 model_errors .append (error )
151160 # Ensure the instances contain valid parent references for foreign keys
@@ -419,13 +428,8 @@ def imported_communities(
419428 """
420429 Communities from a BSS, imported to the Django database using a fixture.
421430 """
422- fixture , metadata = get_fixture_from_instances (community_instances )
423- metadata = import_fixture (fixture )
424-
425- return Output (
426- None ,
427- metadata = metadata ,
428- )
431+ output = get_fixture_from_instances (community_instances )
432+ return import_fixture (output .value )
429433
430434
431435@asset (partitions_def = bss_instances_partitions_def )
0 commit comments