dpdtrack/test.py

22 lines
707 B
Python
Raw Normal View History

2023-08-16 09:28:38 +00:00
from unittest import TestCase, main
from configparser import ConfigParser
import json
2023-08-24 18:02:51 +00:00
from glsapi 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-24 18:02:51 +00:00
class TestGLSAPI(TestCase):
def setUp(self):
self.api = GLSAPI()
2023-08-16 09:28:38 +00:00
2023-08-24 18:02:51 +00:00
def test_gls_api(self):
tracking_number = "483432314669"
response = self.api.tracking(tracking_number)
unitno = [x for x in response["tuStatus"][0]["references"] if x["type"] == "UNITNO"][0]["value"]
self.assertTrue(tracking_number.startswith(unitno))