Skip to content

Commit 8a01f54

Browse files
committed
fixed imports, logging, added test for location service
* made sure imports compatible when running tests with nosetests or straight python. * added basic minimal test for location service. * added default logging when using straight python to execute tests
1 parent 8ac2e38 commit 8a01f54

10 files changed

+38
-15
lines changed

tests/test_address_validation_service.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from fedex.services.address_validation_service import FedexAddressValidationRequest
1111

1212
# Common global config object for testing.
13-
from common import get_fedex_config
13+
from tests.common import get_fedex_config
1414

1515
CONFIG_OBJ = get_fedex_config()
1616

@@ -41,4 +41,5 @@ def test_avs(self):
4141

4242

4343
if __name__ == "__main__":
44+
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
4445
unittest.main()

tests/test_availability_commitment_service.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from fedex.services.availability_commitment_service import FedexAvailabilityCommitmentRequest
1111

1212
# Common global config object for testing.
13-
from common import get_fedex_config
13+
from tests.common import get_fedex_config
1414

1515
CONFIG_OBJ = get_fedex_config()
1616

@@ -40,4 +40,5 @@ def test_track(self):
4040

4141

4242
if __name__ == "__main__":
43+
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
4344
unittest.main()

tests/test_config_object.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44

55
import unittest
6-
6+
import logging
77
import sys
88

99
sys.path.insert(0, '..')
@@ -35,4 +35,5 @@ def test_fedex_config(self):
3535

3636

3737
if __name__ == "__main__":
38+
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
3839
unittest.main()

tests/test_country_service.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from fedex.services.country_service import FedexValidatePostalRequest
1111

1212
# Common global config object for testing.
13-
from common import get_fedex_config
13+
from tests.common import get_fedex_config
1414

1515
CONFIG_OBJ = get_fedex_config()
1616

@@ -35,4 +35,5 @@ def test_postal_inquiry(self):
3535

3636

3737
if __name__ == "__main__":
38+
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
3839
unittest.main()

tests/test_location_service.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,18 @@
33
"""
44

55
import unittest
6-
6+
import logging
77
import sys
88

99
sys.path.insert(0, '..')
1010
from fedex.services.location_service import FedexSearchLocationRequest
1111

1212
# Common global config object for testing.
13-
from common import get_fedex_config
13+
from tests.common import get_fedex_config
1414

1515
CONFIG_OBJ = get_fedex_config()
1616

17+
logging.getLogger('suds').setLevel(logging.ERROR)
1718

1819
@unittest.skipIf(not CONFIG_OBJ.account_number, "No credentials provided.")
1920
class SearchLocationServiceTests(unittest.TestCase):
@@ -32,13 +33,20 @@ def test_location_phone_search(self):
3233

3334
location_request.Constraints.LocationTypesToInclude = ['FEDEX_AUTHORIZED_SHIP_CENTER']
3435

35-
location_request.Address.PostalCode = '38119'
36-
location_request.Address.CountryCode = 'US'
36+
location_request.Address.PostalCode = 'M5V 1Z0'
37+
location_request.Address.CountryCode = 'CA'
3738

3839
location_request.send_request()
3940

4041
assert location_request.response
4142

43+
def test_location_address_search(self):
44+
# Test search by address, using minimum parameters
45+
46+
location_request = FedexSearchLocationRequest(CONFIG_OBJ)
47+
location_request.Address.PostalCode = '38119'
48+
location_request.Address.CountryCode = 'US'
4249

4350
if __name__ == "__main__":
51+
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
4452
unittest.main()

tests/test_package_movement_service.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
import logging
77
import sys
88

9-
sys.path.insert(0, '..')
9+
sys.path.insert(0, '../')
1010
from fedex.services.package_movement import PostalCodeInquiryRequest
1111

1212
# Common global config object for testing.
13-
from common import get_fedex_config
13+
from tests.common import get_fedex_config
1414

1515
CONFIG_OBJ = get_fedex_config()
1616

@@ -23,8 +23,14 @@ class PackageMovementServiceTests(unittest.TestCase):
2323
These tests verify that the package movement service WSDL is in good shape.
2424
"""
2525

26+
def setUp(self):
27+
self.config_obj = get_fedex_config()
28+
29+
def tearDown(self):
30+
pass
31+
2632
def test_postal_inquiry(self):
27-
inquiry = PostalCodeInquiryRequest(CONFIG_OBJ)
33+
inquiry = PostalCodeInquiryRequest(self.config_obj)
2834
inquiry.PostalCode = '29631'
2935
inquiry.CountryCode = 'US'
3036

@@ -35,4 +41,5 @@ def test_postal_inquiry(self):
3541

3642

3743
if __name__ == "__main__":
44+
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
3845
unittest.main()

tests/test_rate_service.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from fedex.services.rate_service import FedexRateServiceRequest
1111

1212
# Common global config object for testing.
13-
from common import get_fedex_config
13+
from tests.common import get_fedex_config
1414

1515
CONFIG_OBJ = get_fedex_config()
1616

@@ -56,4 +56,5 @@ def test_rate(self):
5656

5757

5858
if __name__ == "__main__":
59+
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
5960
unittest.main()

tests/test_ship_service.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from fedex.services.ship_service import FedexDeleteShipmentRequest
1212

1313
# Common global config object for testing.
14-
from common import get_fedex_config
14+
from tests.common import get_fedex_config
1515

1616
CONFIG_OBJ = get_fedex_config()
1717

@@ -90,4 +90,5 @@ def test_create_delete_shipment(self):
9090

9191

9292
if __name__ == "__main__":
93+
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
9394
unittest.main()

tests/test_tools.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44

55
import unittest
6-
6+
import logging
77
import sys
88

99
sys.path.insert(0, '..')
@@ -41,4 +41,5 @@ def test_conversion_tools(self):
4141
assert dict_obj, "Expecting a JSON string object."
4242

4343
if __name__ == "__main__":
44+
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
4445
unittest.main()

tests/test_track_service.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from fedex.services.track_service import FedexTrackRequest
1111

1212
# Common global config object for testing.
13-
from common import get_fedex_config
13+
from tests.common import get_fedex_config
1414

1515
CONFIG_OBJ = get_fedex_config()
1616

@@ -50,4 +50,5 @@ def test_track(self):
5050

5151

5252
if __name__ == "__main__":
53+
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
5354
unittest.main()

0 commit comments

Comments
 (0)