"""Testing the USPhysicalRetailerAggregateView.""" from collections import OrderedDict from decimal import Decimal from reporting.constants.field import LIMIT from reporting.models.us_physical_retailer_aggregate_view_coop import ( USPhysicalRetailerAggregateViewCoop, ) def default_params(): """Get the default params.""" return { 'param_artist': [], 'param_inventory_data': True, 'param_product_name': [], 'param_retailer': [], 'param_product_type': [], 'param_sales_data': True, 'param_release_date': '', 'param_sub_label': [], 'param_vendor_id': [7], } def test_standard_query(): """Test the standard query.""" results = USPhysicalRetailerAggregateViewCoop.all(default_params()) expected = OrderedDict() expected['Retailer'] = 'Retailer7' expected['Retailer Code'] = 7 expected['Open Orders'] = 1 expected['Backorders'] = 1 expected['First4WeekS#'] = 1 expected['5DayS#'] = 1 expected['5DayR#'] = 1 expected['Last4WkS#'] = 1 expected['Last4WkR#'] = 1 expected['MTDS#'] = 1 expected['MTDR#'] = 1 expected['CYTDS#'] = 1 expected['CYTDR#'] = 1 expected['CumTDS#'] = 1 expected['CumTDR#'] = 1 expected['Total RTD Co-Op $'] = Decimal('6.00') expected['Closed Co-Op $'] = Decimal('3.00') expected['Open Co-Op $'] = Decimal('3.00') content = results.message['content'] row = next(r for r in content if r['Retailer Code'] == 7) assert row == expected assert len(content) == 2 assert len(results.message['columns']) == 18 def test_limit(): """Test limit.""" params = default_params() params[LIMIT] = 1 results = USPhysicalRetailerAggregateViewCoop.all(params) assert len(results.message['content']) == 1