Beispiel #1
0
    def test_get_info_calls(self, http_mock):
        with patch.object(CanadaPostProxy, "_get_info",
                          return_value="<a></a>") as get_info_mock:
            proxy_ = CanadaPostProxy(proxy.client)
            proxy_.create_shipment(self.NCShipment)

            link = xml_tostring(get_info_mock.call_args[0][0])
            self.assertEqual(strip(link), strip(ShipmentPriceLinkXML))
Beispiel #2
0
    def test_get_quotes(self, http_mock):
        proxy.get_quotes(self.mailing_scenario)

        xmlStr = http_mock.call_args[1]["data"].decode("utf-8")
        reqUrl = http_mock.call_args[1]["url"]
        self.assertEqual(strip(xmlStr), strip(QuoteRequestXml))
        self.assertEqual(reqUrl,
                         "%s/rs/ship/price" % (proxy.client.server_url))
Beispiel #3
0
    def test_modify_pickup(self, http_mock):
        proxy.modify_pickup(self.ModifyPURequest)

        xmlStr = http_mock.call_args[1]["data"].decode("utf-8")
        self.assertEqual(
            strip(xmlStr),
            _reformat_time(
                "CloseTime", _reformat_time("ReadyByTime", strip(ModifyPURequestXML))
            ),
        )
Beispiel #4
0
    def test_freight_get_quotes(self, http_mock):
        proxy.get_quotes(self.FreightRateRequest)

        xmlStr = http_mock.call_args[1]["data"].decode("utf-8")
        self.assertEqual(strip(xmlStr), strip(FreightRateRequestXML))
Beispiel #5
0
    def test_cancel_pickup(self, http_mock):
        proxy.cancel_pickup(self.CancelPickupRequest)

        xmlStr = http_mock.call_args[1]["data"].decode("utf-8")
        self.assertEqual(strip(xmlStr), strip(PickupCancellationRequestXML))
Beispiel #6
0
    def test_request_pickup(self, http_mock):
        proxy.request_pickup(self.PickupRequest)

        xmlStr = http_mock.call_args[1]["data"].decode("utf-8")
        self.assertEqual(strip(xmlStr), strip(PickupRequestXml))
Beispiel #7
0
    def test_create_ncshipment(self, http_mock):
        proxy.create_shipment(self.NCShipment)

        xmlStr = http_mock.call_args[1]["data"].decode("utf-8")
        self.assertEqual(strip(xmlStr), strip(NCShipmentRequestXML))
Beispiel #8
0
    def test_get_quotes(self, http_mock):
        proxy.get_quotes(self.DCTRequest)

        xmlStr = http_mock.call_args[1]["data"].decode("utf-8")
        self.assertEqual(strip(xmlStr), strip(QuoteRequestXml))
Beispiel #9
0
    def test_get_trackings(self, http_mock):
        proxy.get_trackings(self.KnownTrackingRequest)

        xmlStr = http_mock.call_args[1]["data"].decode("utf-8")
        self.assertEqual(strip(xmlStr), strip(TrackingRequestXml))