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):
|
|
|
|
http = HTTPRequest("https://httpbin.org/get")
|
|
|
|
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-08-24 18:02:51 +00:00
|
|
|
response = self.api.tracking(tracking_number)
|
2023-08-30 09:33:55 +00:00
|
|
|
self.assertEqual(response["state"], "success")
|
|
|
|
self.assertEqual(response["data"][0]["pno"], tracking_number)
|
|
|
|
|
|
|
|
def test_tracking_with_postal_code(self):
|
|
|
|
tracking_number = "01155036780055"
|
|
|
|
postal_code = "8010"
|
|
|
|
response = self.api.tracking(tracking_number, postal_code)
|
|
|
|
self.assertEqual(response["state"], "success")
|
|
|
|
self.assertEqual(response["data"][0]["pno"], tracking_number)
|