"""Test for the ows_pricing module.""" from flexmock import flexmock from owsrequest import request from salessheets.models import ows_pricing def test_get_pricing_for_pricing_family_by_product_and_store_ids(): """Test get_pricing_for_pricing_family_by_product_and_store_ids success.""" product_id = 1 family_id = 2 store_id = 911 price_data = {'price_code': 'No Price Assigned'} content = { 'items': [price_data]} resp = flexmock( status_code=200, json=lambda: content) flexmock(request).should_receive('process').and_return(resp) result = ( ows_pricing.get_pricing_for_pricing_family_by_product_and_store_ids( product_id, family_id, store_id)) assert result assert result.message == price_data def test_get_pricing_for_pricing_family_by_product_and_store_ids_failed(): """Test get_pricing_for_pricing_family_by_product_and_store_ids failed.""" product_id = 1 family_id = 2 store_id = 911 error_content = 'Something went wrong' resp = flexmock( status_code=400, content=error_content) flexmock(request).should_receive('process').and_return(resp) result = ( ows_pricing.get_pricing_for_pricing_family_by_product_and_store_ids( product_id, family_id, store_id)) assert not result assert result.errors['message'] == error_content