예제 #1
0
    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",
        )
예제 #2
0
 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))
예제 #3
0
 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))
예제 #4
0
 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))
예제 #5
0
 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)
         )
예제 #6
0
 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))
예제 #7
0
    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")
예제 #8
0
    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))
예제 #9
0
    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")