2023-08-16 09:28:38 +00:00
|
|
|
from unittest import TestCase, main
|
|
|
|
from configparser import ConfigParser
|
|
|
|
|
|
|
|
import json
|
|
|
|
|
2023-08-30 09:33:55 +00:00
|
|
|
from dpdtrack import *
|
2023-08-16 09:28:38 +00:00
|
|
|
|
|
|
|
class TestHTTPRequest(TestCase):
|
|
|
|
def test_http_request(self):
|
2023-09-21 12:15:26 +00:00
|
|
|
http = HTTPRequest("https://httpbin.kumi.systems/get")
|
2023-08-16 09:28:38 +00:00
|
|
|
response = http.execute()
|
|
|
|
self.assertEqual(response["headers"]["User-Agent"], http.USER_AGENT)
|
|
|
|
|
2023-08-30 09:33:55 +00:00
|
|
|
class TestDPD(TestCase):
|
2023-08-24 18:02:51 +00:00
|
|
|
def setUp(self):
|
2023-08-30 09:33:55 +00:00
|
|
|
self.api = DPD()
|
2023-08-16 09:28:38 +00:00
|
|
|
|
2023-08-30 09:33:55 +00:00
|
|
|
def test_tracking(self):
|
|
|
|
tracking_number = "01155036780055"
|
2023-09-21 12:15:26 +00:00
|
|
|
response = self.api.tracking(tracking_number, wrap=True)
|
|
|
|
self.assertTrue(response.events)
|
|
|
|
self.assertEqual(response.tracking_number, tracking_number)
|
2023-08-30 09:33:55 +00:00
|
|
|
|
|
|
|
def test_tracking_with_postal_code(self):
|
|
|
|
tracking_number = "01155036780055"
|
|
|
|
postal_code = "8010"
|
2023-09-21 12:15:26 +00:00
|
|
|
response = self.api.tracking(tracking_number, postal_code=postal_code, wrap=True)
|
|
|
|
self.assertTrue(response.events)
|
|
|
|
self.assertEqual(response.tracking_number, tracking_number)
|
|
|
|
|
|
|
|
class DPDROTest(TestCase):
|
|
|
|
def setUp(self):
|
|
|
|
self.api = DPDRO()
|
|
|
|
|
|
|
|
def test_tracking(self):
|
|
|
|
tracking_number = "80720052822"
|
|
|
|
response = self.api.tracking(tracking_number, wrap=True)
|
|
|
|
self.assertTrue(response.events)
|
|
|
|
self.assertEqual(response.tracking_number, tracking_number)
|
|
|
|
self.assertEqual(response.remote[0][1], "DPDDE")
|