dhltrack/test.py

27 lines
819 B
Python
Raw Permalink Normal View History

2023-08-16 09:28:38 +00:00
from unittest import TestCase, main
from configparser import ConfigParser
import json
2023-08-29 06:47:16 +00:00
from dhltrack 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-29 06:47:16 +00:00
class TestDHL(TestCase):
2023-08-16 09:28:38 +00:00
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.config = ConfigParser()
self.config.read("config.ini")
2023-08-29 06:47:16 +00:00
self.dhl = DHL.from_config(self.config)
2023-08-16 09:28:38 +00:00
2023-08-27 08:01:47 +00:00
def test_tracking(self):
2023-08-29 06:47:16 +00:00
tracking_number = "LE650235858DE"
response = self.dhl.track(tracking_number)
self.assertEqual(response["shipments"][0]["id"], tracking_number)
2023-08-16 09:28:38 +00:00
if __name__ == "__main__":
main()