|
| 1 | +""" |
| 2 | +Test module for the Fedex Pickup Service WSDL. |
| 3 | +""" |
| 4 | + |
| 5 | +import unittest |
| 6 | +import logging |
| 7 | +import sys |
| 8 | +import datetime |
| 9 | + |
| 10 | +sys.path.insert(0, '..') |
| 11 | +from fedex.services.pickup_service import FedexCreatePickupRequest |
| 12 | + |
| 13 | +# Common global config object for testing. |
| 14 | +from tests.common import get_fedex_config |
| 15 | + |
| 16 | +CONFIG_OBJ = get_fedex_config() |
| 17 | + |
| 18 | +logging.getLogger('suds').setLevel(logging.ERROR) |
| 19 | +logging.getLogger('fedex').setLevel(logging.INFO) |
| 20 | + |
| 21 | + |
| 22 | +@unittest.skipIf(not CONFIG_OBJ.account_number, "No credentials provided.") |
| 23 | +class FedexCreatePickupRequestTests(unittest.TestCase): |
| 24 | + """ |
| 25 | + These tests verify that the rate service WSDL is in good shape. |
| 26 | + """ |
| 27 | + |
| 28 | + def test_rate(self): |
| 29 | + pickup_service = FedexCreatePickupRequest(CONFIG_OBJ) |
| 30 | + |
| 31 | + pickup_service.OriginDetail.PickupLocation.Contact.PersonName = 'Sender Name' |
| 32 | + pickup_service. OriginDetail. PickupLocation. Contact. EMailAddress = '[email protected]' |
| 33 | + pickup_service.OriginDetail.PickupLocation.Contact.CompanyName = 'Acme Inc.' |
| 34 | + pickup_service.OriginDetail.PickupLocation.Contact.PhoneNumber = '9012638716' |
| 35 | + pickup_service.OriginDetail.PickupLocation.Address.StateOrProvinceCode = 'SC' |
| 36 | + pickup_service.OriginDetail.PickupLocation.Address.PostalCode = '29631' |
| 37 | + pickup_service.OriginDetail.PickupLocation.Address.CountryCode = 'US' |
| 38 | + pickup_service.OriginDetail.PickupLocation.Address.StreetLines = ['155 Old Greenville Hwy', 'Suite 103'] |
| 39 | + pickup_service.OriginDetail.PickupLocation.Address.City = 'Clemson' |
| 40 | + # pickup_service.OriginDetail.PickupLocation.Address.UrbanizationCode = '' # For Puerto Rico only |
| 41 | + pickup_service.OriginDetail.PickupLocation.Address.Residential = False |
| 42 | + |
| 43 | + # FRONT, NONE, REAR, SIDE |
| 44 | + # pickup_service.OriginDetail.PackageLocation = 'NONE' |
| 45 | + |
| 46 | + # APARTMENT, BUILDING, DEPARTMENT, FLOOR, ROOM, SUITE |
| 47 | + # pickup_service.OriginDetail.BuildingPart = 'SUITE' |
| 48 | + |
| 49 | + # Identifies the date and time the package will be ready for pickup by FedEx. |
| 50 | + pickup_service.OriginDetail.ReadyTimestamp = datetime.datetime.now().replace(microsecond=0).isoformat() |
| 51 | + |
| 52 | + # Identifies the latest time at which the driver can gain access to pick up the package(s) |
| 53 | + pickup_service.OriginDetail.CompanyCloseTime = '23:00:00' |
| 54 | + |
| 55 | + pickup_service.CarrierCode = 'FDXE' |
| 56 | + |
| 57 | + pickup_service.TotalWeight.Units = 'LB' |
| 58 | + pickup_service.TotalWeight.Value = '1' |
| 59 | + pickup_service.PackageCount = '1' |
| 60 | + # pickup_service.OversizePackageCount = '1' |
| 61 | + |
| 62 | + # pickup_service.CommodityDescription = '' |
| 63 | + |
| 64 | + # DOMESTIC or INTERNATIONAL |
| 65 | + # pickup_service.CountryRelationship = 'DOMESTIC' |
| 66 | + |
| 67 | + # See PickupServiceCategoryType |
| 68 | + # pickup_service.PickupServiceCategory = 'FEDEX_DISTANCE_DEFERRED' |
| 69 | + |
| 70 | + pickup_service.send_request() |
| 71 | + |
| 72 | + assert pickup_service.response.HighestSeverity == 'SUCCESS', pickup_service.response.Notifications[0].Message |
| 73 | + |
| 74 | + |
| 75 | +if __name__ == "__main__": |
| 76 | + logging.basicConfig(stream=sys.stdout, level=logging.INFO) |
| 77 | + unittest.main() |
0 commit comments