1010from apps .wildfire .models import Wildfire
1111from apps .wildfire .tasks import populate_all_wildfire_data , populate_wildfire_from_data
1212from apps .wildfire .tests .test_data .wildfire_parsed_feed import parsed_feed
13- from django .contrib .gis .geos import MultiPolygon , Point , Polygon
13+ from django .contrib .gis .geos import MultiPolygon , Point
1414from httpx import HTTPStatusError
1515
1616# suppress logged error messages to reduce noise
@@ -50,17 +50,9 @@ def setUp(self):
5050 self .parsed_feed = parsed_feed
5151
5252 def test_populate_wildfire_function (self ):
53- # Polygon/Under Control
54- populate_wildfire_from_data (self .parsed_feed [0 ])
55- wildfire_one = Wildfire .objects .get (id = 'C50627' )
56- assert wildfire_one .id == 'C50627'
57- assert wildfire_one .url == 'https://wildfiresituation.nrs.gov.bc.ca/incidents?fireYear=2025&incidentNumber=C50627'
58- assert wildfire_one .name == 'Martin Lake'
59- assert isinstance (wildfire_one .location , Point )
60- assert isinstance (wildfire_one .geometry , Polygon )
61- assert wildfire_one .size == 2244.5
62- assert wildfire_one .status == "Under Control"
63- assert wildfire_one .reported_date == datetime .date (2025 , 6 , 15 )
53+ # Under Control, not populated
54+ assert populate_wildfire_from_data (self .parsed_feed [0 ]) is None
55+ assert not Wildfire .objects .filter (id = 'C50627' ).exists ()
6456
6557 # Out, not populated
6658 populate_wildfire_from_data (self .parsed_feed [1 ])
@@ -78,6 +70,14 @@ def test_populate_wildfire_function(self):
7870 assert wildfire_two .status == "Being Held"
7971 assert wildfire_two .reported_date == datetime .date (2025 , 5 , 28 )
8072
73+ # Point-only/Out of Control
74+ populate_wildfire_from_data (self .parsed_feed [3 ])
75+ wildfire_three = Wildfire .objects .get (id = 'V12345' )
76+ assert wildfire_three .name == 'Point Only Fire'
77+ assert isinstance (wildfire_three .location , Point )
78+ assert isinstance (wildfire_three .geometry , Point )
79+ assert wildfire_three .status == "Out of Control"
80+
8181 @patch ("httpx.get" )
8282 def test_populate_and_update_wildfires (self , mock_requests_get ):
8383 mock_requests_get .side_effect = [
@@ -90,10 +90,7 @@ def test_populate_and_update_wildfires(self, mock_requests_get):
9090 populate_all_wildfire_data ()
9191
9292 # validate data
93- assert Wildfire .objects .count () == 2 # wildfires with "Out" not populated
94- wildfire_one = Wildfire .objects .get (id = 'C50627' )
95- assert wildfire_one .reported_date == datetime .date (2025 , 6 , 15 )
96-
93+ assert Wildfire .objects .count () == 1 # only Being Held wildfires are populated
9794 wildfire_two = Wildfire .objects .get (id = 'G70422' )
9895 assert wildfire_two .reported_date == datetime .date (2025 , 5 , 28 )
9996
0 commit comments