| import unittest |
|
|
| from app import _resolve_project_fields |
| from src.models import SiteSelection |
|
|
|
|
| class AppDefaultTests(unittest.TestCase): |
| def test_polygon_only_metadata_is_auto_labelled(self): |
| selection = SiteSelection( |
| id="S1", |
| selection_type="drawn_polygon", |
| coordinate_mode="wgs84", |
| geometry_geojson={"type": "Polygon", "coordinates": []}, |
| local_geometry=None, |
| anchor_lat=21.00248, |
| anchor_lon=70.24537, |
| radius_m=None, |
| area_sqm=11978, |
| perimeter_m=439, |
| centroid=(21.00248, 70.24537), |
| bbox=(70.2447, 21.0019, 70.246, 21.003), |
| unit_source="WGS84 drawn map", |
| accuracy_label="user-drawn approximate boundary", |
| source_files=[], |
| selected_boundary_id=None, |
| limitations=["Drawn map boundaries are approximate."], |
| ) |
|
|
| project, site, project_type, source, warnings = _resolve_project_fields( |
| project_name="", |
| site_name="", |
| project_type="", |
| boundary_source="", |
| selection=selection, |
| site_identity={"city": "Chorwad", "state": "Gujarat", "country": "India"}, |
| ) |
|
|
| self.assertEqual(project, "Preliminary Site Analysis") |
| self.assertEqual(site, "Chorwad selected site") |
| self.assertEqual(project_type, "Early-stage architecture site analysis") |
| self.assertIn("User-drawn boundary", source) |
| self.assertGreaterEqual(len(warnings), 3) |
|
|
| def test_default_untitled_site_is_replaced(self): |
| selection = SiteSelection( |
| id="S2", |
| selection_type="pin_radius", |
| coordinate_mode="wgs84", |
| geometry_geojson=None, |
| local_geometry=None, |
| anchor_lat=21.0, |
| anchor_lon=70.0, |
| radius_m=250, |
| area_sqm=196349.5, |
| perimeter_m=1570.8, |
| centroid=(21.0, 70.0), |
| bbox=None, |
| unit_source="meters", |
| accuracy_label="pin-radius approximation", |
| source_files=[], |
| selected_boundary_id=None, |
| limitations=["This is approximate context analysis."], |
| ) |
|
|
| _, site, _, source, _ = _resolve_project_fields( |
| project_name="Architecture Site Analysis", |
| site_name="Untitled site", |
| project_type="", |
| boundary_source="", |
| selection=selection, |
| site_identity=None, |
| ) |
|
|
| self.assertEqual(site, "Selected site 21.00000, 70.00000") |
| self.assertIn("pin and radius", source) |
|
|
|
|
| if __name__ == "__main__": |
| unittest.main() |
|
|