Spaces:
Running
Running
| """Quick test to verify listing serialization""" | |
| import asyncio | |
| from app.models.listing import Listing | |
| def test_serialization(): | |
| # Test with address and coordinates | |
| doc = { | |
| 'user_id': '123', | |
| 'listing_type': 'rent', | |
| 'title': 'Test Property', | |
| 'description': 'Test description for property', | |
| 'price': 100000, | |
| 'price_type': 'monthly', | |
| 'location': 'Lagos', | |
| 'address': 'Victoria Island, Lagos', | |
| 'latitude': 6.4281, | |
| 'longitude': 3.4219, | |
| 'status': 'active' | |
| } | |
| listing = Listing(**doc) | |
| print("=== Listing Object Fields ===") | |
| print(f"address: {listing.address}") | |
| print(f"latitude: {listing.latitude}") | |
| print(f"longitude: {listing.longitude}") | |
| print("\n=== listing.dict(by_alias=True) ===") | |
| result = listing.dict(by_alias=True) | |
| print(f"address in result: {'address' in result}") | |
| print(f"address value: {result.get('address')}") | |
| print(f"latitude value: {result.get('latitude')}") | |
| print(f"longitude value: {result.get('longitude')}") | |
| print("\n=== Full Result ===") | |
| for key in ['address', 'latitude', 'longitude', 'location']: | |
| print(f" {key}: {result.get(key)}") | |
| if __name__ == "__main__": | |
| test_serialization() | |