File size: 1,283 Bytes
5a6c225
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
"""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()