2024-09-06 06:28:37 +00:00
|
|
|
from unittest import TestCase
|
2023-08-16 09:28:38 +00:00
|
|
|
|
2024-09-06 06:28:37 +00:00
|
|
|
from track4px import HTTPRequest, Track4PX
|
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)
|
|
|
|
|
2024-09-06 06:28:37 +00:00
|
|
|
class TestTrack4PX(TestCase):
|
2023-09-21 12:15:26 +00:00
|
|
|
def setUp(self):
|
2024-09-06 06:28:37 +00:00
|
|
|
self.api = Track4PX()
|
2023-09-21 12:15:26 +00:00
|
|
|
|
|
|
|
def test_tracking(self):
|
2024-09-06 06:28:37 +00:00
|
|
|
tracking_number = "4PX3001291278502CN"
|
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)
|