@@ -112,11 +112,26 @@ def test_park_priority_basic_functionality(
112112 self .assertIn ("park_priority" , second_arg .columns )
113113 self .assertNotIn ("parkneed" , second_arg .columns )
114114
115- # Check return values - focus on object identity and type, not exact equality
116- self .assertIs (result_gdf , mock_spatial_join .return_value )
115+ # Check return values - use data equality instead of object identity
117116 self .assertIsInstance (result_gdf , gpd .GeoDataFrame )
118117 self .assertIsInstance (validation_result , ValidationResult )
119- # Use the mock return value instead of comparing objects
118+
119+ # Check data equality for the GeoDataFrame
120+ pd .testing .assert_frame_equal (
121+ result_gdf .drop (columns = ["geometry" ]),
122+ expected_result_gdf .drop (columns = ["geometry" ]),
123+ check_dtype = False ,
124+ )
125+
126+ # Check geometry column separately
127+ for i , (expected_geom , actual_geom ) in enumerate (
128+ zip (expected_result_gdf .geometry , result_gdf .geometry )
129+ ):
130+ self .assertTrue (
131+ expected_geom .equals (actual_geom ), f"Geometry mismatch at index { i } "
132+ )
133+
134+ # Check validation result
120135 self .assertIs (validation_result , mock_validation_result )
121136
122137 @patch ("src.data_utils.park_priority.EsriLoader" )
@@ -176,8 +191,25 @@ def test_park_priority_column_renaming(
176191 self .assertNotIn ("parkneed" , second_arg .columns )
177192 self .assertEqual (second_arg ["park_priority" ].iloc [0 ], 5.0 )
178193
179- # Check return value - focus on object identity
180- self .assertIs (result_gdf , mock_spatial_join .return_value )
194+ # Check return value - use data equality instead of object identity
195+ self .assertIsInstance (result_gdf , gpd .GeoDataFrame )
196+
197+ # Check data equality for the GeoDataFrame
198+ pd .testing .assert_frame_equal (
199+ result_gdf .drop (columns = ["geometry" ]),
200+ expected_result_gdf .drop (columns = ["geometry" ]),
201+ check_dtype = False ,
202+ )
203+
204+ # Check geometry column separately
205+ for i , (expected_geom , actual_geom ) in enumerate (
206+ zip (expected_result_gdf .geometry , result_gdf .geometry )
207+ ):
208+ self .assertTrue (
209+ expected_geom .equals (actual_geom ), f"Geometry mismatch at index { i } "
210+ )
211+
212+ # Check validation result
181213 self .assertIs (validation_result , mock_validation_result )
182214
183215 @patch ("src.data_utils.park_priority.EsriLoader" )
@@ -261,9 +293,25 @@ def test_park_priority_empty_data(self, mock_spatial_join, mock_esri_loader_clas
261293 result_gdf , validation_result = _park_priority_logic (input_gdf )
262294
263295 # Check that the function handles empty data gracefully
264- self .assertIs (result_gdf , mock_spatial_join .return_value )
265296 self .assertIsInstance (result_gdf , gpd .GeoDataFrame )
266297 self .assertIsInstance (validation_result , ValidationResult )
298+
299+ # Check data equality for the GeoDataFrame
300+ pd .testing .assert_frame_equal (
301+ result_gdf .drop (columns = ["geometry" ]),
302+ input_gdf .drop (columns = ["geometry" ]),
303+ check_dtype = False ,
304+ )
305+
306+ # Check geometry column separately
307+ for i , (expected_geom , actual_geom ) in enumerate (
308+ zip (input_gdf .geometry , result_gdf .geometry )
309+ ):
310+ self .assertTrue (
311+ expected_geom .equals (actual_geom ), f"Geometry mismatch at index { i } "
312+ )
313+
314+ # Check validation result
267315 self .assertIs (validation_result , mock_validation_result )
268316
269317 # Check that spatial_join was still called (even with empty data)
@@ -324,8 +372,23 @@ def test_park_priority_return_format(
324372 # Check second element is ValidationResult
325373 self .assertIsInstance (validation_result , ValidationResult )
326374
327- # Check the actual values - focus on object identity
328- self .assertIs (result_gdf , mock_spatial_join .return_value )
375+ # Check the actual values - use data equality instead of object identity
376+ # Check data equality for the GeoDataFrame
377+ pd .testing .assert_frame_equal (
378+ result_gdf .drop (columns = ["geometry" ]),
379+ expected_result_gdf .drop (columns = ["geometry" ]),
380+ check_dtype = False ,
381+ )
382+
383+ # Check geometry column separately
384+ for i , (expected_geom , actual_geom ) in enumerate (
385+ zip (expected_result_gdf .geometry , result_gdf .geometry )
386+ ):
387+ self .assertTrue (
388+ expected_geom .equals (actual_geom ), f"Geometry mismatch at index { i } "
389+ )
390+
391+ # Check validation result
329392 self .assertIs (validation_result , mock_validation_result )
330393
331394 @pytest .mark .skip
0 commit comments