|
|
""" |
|
|
Simple test to verify format conversion logic |
|
|
""" |
|
|
|
|
|
|
|
|
def test_legacy_conversion(): |
|
|
"""Test that legacy format gets converted correctly""" |
|
|
|
|
|
|
|
|
risk_data = { |
|
|
"location": { |
|
|
"name": "Manila", |
|
|
"coordinates": {"latitude": 14.5995, "longitude": 120.9842} |
|
|
}, |
|
|
"hazards": {"seismic": {}, "volcanic": {}, "hydrometeorological": {}} |
|
|
} |
|
|
building_type = "residential_single_family" |
|
|
recommendations = {"general_guidelines": ["Test"]} |
|
|
|
|
|
|
|
|
construction_data = { |
|
|
"building_type": building_type, |
|
|
"risk_data": risk_data |
|
|
} |
|
|
|
|
|
if recommendations: |
|
|
construction_data["recommendations"] = recommendations |
|
|
|
|
|
if isinstance(risk_data, dict) and "location" in risk_data: |
|
|
construction_data["location"] = risk_data["location"] |
|
|
|
|
|
|
|
|
building_descriptions = { |
|
|
"residential_single_family": "single-family home", |
|
|
"residential_multi_family": "multi-family residential building", |
|
|
"residential_high_rise": "high-rise apartment building", |
|
|
"commercial_office": "modern office building", |
|
|
"commercial_retail": "retail shopping center", |
|
|
"industrial_warehouse": "industrial warehouse facility", |
|
|
"institutional_school": "school building", |
|
|
"institutional_hospital": "hospital or healthcare facility", |
|
|
"infrastructure_bridge": "bridge structure", |
|
|
"mixed_use": "mixed-use development" |
|
|
} |
|
|
building_desc = building_descriptions.get(building_type, "building") |
|
|
prompt = f"Generate an architectural visualization of a {building_desc} in the Philippines with disaster-resistant features" |
|
|
|
|
|
|
|
|
print("Legacy Format Conversion Test") |
|
|
print("=" * 60) |
|
|
print(f"Input:") |
|
|
print(f" - building_type: {building_type}") |
|
|
print(f" - risk_data: {bool(risk_data)}") |
|
|
print(f" - recommendations: {bool(recommendations)}") |
|
|
print() |
|
|
print(f"Output:") |
|
|
print(f" - prompt: {prompt}") |
|
|
print(f" - construction_data keys: {list(construction_data.keys())}") |
|
|
print() |
|
|
|
|
|
|
|
|
assert prompt is not None, "Prompt should be generated" |
|
|
assert "single-family home" in prompt, "Prompt should contain building description" |
|
|
assert "Philippines" in prompt, "Prompt should mention Philippines" |
|
|
assert "disaster-resistant" in prompt, "Prompt should mention disaster-resistant" |
|
|
|
|
|
assert "building_type" in construction_data, "construction_data should have building_type" |
|
|
assert "risk_data" in construction_data, "construction_data should have risk_data" |
|
|
assert "recommendations" in construction_data, "construction_data should have recommendations" |
|
|
assert "location" in construction_data, "construction_data should have location" |
|
|
|
|
|
print("β
All assertions passed!") |
|
|
print(" Legacy format successfully converts to new format") |
|
|
print("=" * 60) |
|
|
|
|
|
return True |
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
try: |
|
|
test_legacy_conversion() |
|
|
except AssertionError as e: |
|
|
print(f"β Test failed: {e}") |
|
|
exit(1) |
|
|
except Exception as e: |
|
|
print(f"β Unexpected error: {e}") |
|
|
import traceback |
|
|
traceback.print_exc() |
|
|
exit(1) |
|
|
|