"""Tests for streams_by_product_schema module.""" from sound_recordings.schemas import streams_by_product STREAMS = [ { "product_id": "123", "items": [ { "date": "2021-01-16T00:00:00Z", "streams": 1000, "skip_rate": 0.325823532, "saves": 500, }, { "date": "2021-01-17T00:00:00Z", "streams": 500, "skip_rate": 0.2597351, "saves": 125, }, ], }, { "product_id": "321", "items": [ { "date": "2021-01-16T00:00:00Z", "streams": 1500, "skip_rate": 0.421415667, "saves": 700, }, { "date": "2021-01-17T00:00:00Z", "streams": 300, "skip_rate": 0.1245356, "saves": 100, }, ], }, ] def test_streams_by_product_schema(): """Test that streams_by_product schema converts to JSON object.""" input_data = {"isrc": "TEST", "products": STREAMS} expected_result = {"isrc": "TEST", "products": STREAMS} result = streams_by_product.StreamsByProductSchema().dump(input_data) assert result == expected_result