"""Tests for top_markets_schema module.""" from decimal import Decimal from analytics.schemas import top_markets def test_top_markets_schema(): """Test that top_markets_schema properly converts to JSON object.""" mock_model_response = { "isrc": "TEST", "items": [ { "country_code": "UA", "orchard_region_name": "Kyiv", "streams_7_days": 42, "growth_percentage": Decimal(0.333333), }, { "country_code": "US", "orchard_region_name": "NYC", "streams_7_days": 37, "growth_percentage": Decimal(0.42), }, ], "sources": [ {"id": 286, "name": "Spotify"}, ], } expected_result = { "isrc": "TEST", "items": [ { "country_code": "UA", "streams": 42, "region": "Kyiv", "growth_percentage": 0.333333, }, { "country_code": "US", "streams": 37, "region": "NYC", "growth_percentage": 0.42, }, ], "sources": [ {"id": 286, "name": "Spotify"}, ], } result = top_markets.TopMarketsSchema().dump(mock_model_response) assert result == expected_result