def test_create_rate(self, http_mock): Rating.fetch(self.RateRequest).from_(gateway) url = http_mock.call_args[1]["url"] self.assertEqual( url, f"{gateway.settings.server_url}/EWS/V2/Estimating/EstimatingService.asmx", )
def test_parse_intl_quote_response(self): with patch("purplship.package.mappers.usps.proxy.http") as mock: mock.return_value = INTL_RATE_RESPONSE parsed_response = Rating.fetch( self.RateRequest).from_(gateway).parse() self.assertEqual(to_dict(parsed_response), to_dict(PARSED_INTL_RATE_RESPONSE))
def test_parse_rate_missing_args_error(self): with patch("purplship.package.mappers.canadapost.proxy.http") as mock: mock.return_value = QuoteMissingArgsError parsed_response = Rating.fetch( self.RateRequest).from_(gateway).parse() self.assertEqual(to_dict(parsed_response), to_dict(ParsedQuoteMissingArgsError))
def test_parse_rate_error_response(self): with patch("purplship.package.mappers.fedex.proxy.http") as mock: mock.return_value = RateErrorResponseXml parsed_response = Rating.fetch( self.RateRequest).from_(gateway).parse() self.assertEqual(to_dict(parsed_response), to_dict(ParsedRateErrorResponse))
def test_parse_rate_vol_weight_higher_response(self): with patch("purplship.package.mappers.dhl.proxy.http") as mock: mock.return_value = RateVolWeightHigher parsed_response = Rating.fetch(self.RateRequest).from_(gateway).parse() self.assertEqual( to_dict(parsed_response), to_dict(ParsedRateVolWeightHigher) )
def test_parse_rate_response_errors(self): with patch("purplship.package.mappers.usps.proxy.http") as mock: mock.return_value = ERRORS parsed_response = Rating.fetch( self.RateRequest).from_(gateway).parse() self.assertEqual(to_dict(parsed_response), to_dict(PARSED_ERRORS))
def test_get_rates(self, http_mock): Rating.fetch(self.RateRequest).from_(gateway) url = http_mock.call_args[1]["url"] self.assertEqual(url, f"{gateway.proxy.settings.server_url}/rs/ship/price")
def test_create_rate_request_with_package_preset_missing_weight(self, _): processing_error = (Rating.fetch( RateRequest( **RateWithPresetMissingWeightPayload)).from_(gateway).parse()) self.assertEqual(to_dict(processing_error), to_dict(ProcessingError))
def test_package_get_quotes(self, http_mock): Rating.fetch(self.RateRequest).from_(gateway) url = http_mock.call_args[1]["url"] self.assertEqual(url, f"{gateway.settings.server_url}/Rate")