@@ -169,35 +169,27 @@ def test_mixed_statuses(self, tenants_fixture, scans_fixture):
169169 assert result ["check_1" ]["passed" ] == 1
170170 assert result ["check_1" ]["total" ] == 1
171171
172- def test_excludes_findings_without_resources (self , tenants_fixture , scans_fixture ):
173- """Verify findings without resources are excluded from aggregation."""
172+ def test_skips_aggregation_for_deleted_provider (
173+ self , tenants_fixture , scans_fixture
174+ ):
175+ """Verify aggregation returns empty when the scan's provider is soft-deleted."""
174176 tenant = tenants_fixture [0 ]
175177 scan = scans_fixture [0 ]
176178
177- # Finding WITH resource → should be counted
178179 self ._create_finding_with_resource (
179180 tenant , scan , "finding-1" , "check_1" , StatusChoices .PASS
180181 )
181182
182- # Finding WITHOUT resource → should be EXCLUDED
183- Finding .objects .create (
184- tenant_id = tenant .id ,
185- scan = scan ,
186- uid = "finding-2" ,
187- check_id = "check_1" ,
188- status = StatusChoices .FAIL ,
189- severity = Severity .high ,
190- impact = Severity .high ,
191- check_metadata = {},
192- raw_result = {},
193- )
183+ # Soft-delete the provider
184+ provider = scan .provider
185+ provider .is_deleted = True
186+ provider .save (update_fields = ["is_deleted" ])
194187
195188 result = _aggregate_requirement_statistics_from_database (
196189 str (tenant .id ), str (scan .id )
197190 )
198191
199- assert result ["check_1" ]["passed" ] == 1
200- assert result ["check_1" ]["total" ] == 1
192+ assert result == {}
201193
202194 def test_multiple_resources_no_double_count (self , tenants_fixture , scans_fixture ):
203195 """Verify a finding with multiple resources is only counted once."""
0 commit comments