refactor: update unit tests to use Track4PX API

Replaced DPD API references with Track4PX in unit tests to align with the updated API structure. Removed unused imports to clean up the code. This ensures compatibility with the current API implementation and improves maintainability.
This commit is contained in:
Kumi 2024-09-06 08:28:37 +02:00
parent 5a05062267
commit c37fe815c1
Signed by: kumi
GPG key ID: ECBCC9082395383F
2 changed files with 5 additions and 28 deletions

View file

@ -2,8 +2,6 @@ from datetime import datetime
import json
import bs4
from .http import HTTPRequest
from .shipment import Shipment, Event

31
test.py
View file

@ -1,9 +1,6 @@
from unittest import TestCase, main
from configparser import ConfigParser
from unittest import TestCase
import json
from dpdtrack import *
from track4px import HTTPRequest, Track4PX
class TestHTTPRequest(TestCase):
def test_http_request(self):
@ -11,30 +8,12 @@ class TestHTTPRequest(TestCase):
response = http.execute()
self.assertEqual(response["headers"]["User-Agent"], http.USER_AGENT)
class TestDPD(TestCase):
class TestTrack4PX(TestCase):
def setUp(self):
self.api = DPD()
self.api = Track4PX()
def test_tracking(self):
tracking_number = "01155036780055"
tracking_number = "4PX3001291278502CN"
response = self.api.tracking(tracking_number, wrap=True)
self.assertTrue(response.events)
self.assertEqual(response.tracking_number, tracking_number)
def test_tracking_with_postal_code(self):
tracking_number = "01155036780055"
postal_code = "8010"
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")