Skip to content

Commit 695cf2f

Browse files
author
Greg Taylor
committed
In the case of an unknown error code, throw a default FedexError exception with the error code and message attached.
1 parent 268b8f9 commit 695cf2f

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

fedex/services/track_service.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,13 @@ def _check_response_for_request_errors(self):
7575
"""
7676
if self.response.HighestSeverity == "ERROR":
7777
for notification in self.response.Notifications:
78-
if "Invalid tracking number" in notification.Message:
79-
raise FedexInvalidTrackingNumber(notification.Code,
80-
notification.Message)
78+
if notification.Severity == "ERROR":
79+
if "Invalid tracking number" in notification.Message:
80+
raise FedexInvalidTrackingNumber(notification.Code,
81+
notification.Message)
82+
else:
83+
raise FedexError(notification.Code,
84+
notification.Message)
8185

8286
def _assemble_and_send_request(self):
8387
"""

tests/t_track_service.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,17 @@ def test_track(self):
1717
Test shipment tracking. Query for a tracking number and make sure the
1818
first (and hopefully only) result matches up.
1919
"""
20-
track_request = FedexTrackRequest(CONFIG_OBJ, '1777768882')
20+
tracking_num = '1777768882'
21+
tracking_num = '799428562846'
22+
tracking_num = '111111111111'
23+
tracking_num = '012301230123'
24+
25+
track_request = FedexTrackRequest(CONFIG_OBJ, tracking_num)
2126
track_request.send_request()
27+
28+
print track_request.response
2229

2330
for match in track_request.response.TrackDetails:
2431
# This should be the same tracking number on the response that we
2532
# asked for in the request.
26-
self.assertEqual(match.TrackingNumber, '1777768882')
33+
self.assertEqual(match.TrackingNumber, tracking_num)

0 commit comments

Comments
 (0)