# Path: fedex/services/track_service.py
# class FedexTrackRequest(FedexBaseService):
#     """
#     This class allows you to track shipments by providing a tracking
#     number or other identifying features. By default, you
#     can simply pass a tracking number to the constructor. If you would like
#     to query shipments based on something other than tracking number, you will
#     want to read the documentation for the L{__init__} method. 
#     Particularly, the tracking_value and package_identifier arguments.
#     """
# 
#     def __init__(self, config_obj, *args, **kwargs):
#         """
#         Sends a shipment tracking request. The optional keyword args
#         detailed on L{FedexBaseService} apply here as well.
#         
#         @type config_obj: L{FedexConfig}
#         @param config_obj: A valid FedexConfig object.
#         """
# 
#         self._config_obj = config_obj
# 
#         # Holds version info for the VersionId SOAP object.
#         self._version_info = {
#             'service_id': 'trck',
#             'major': '16',
#             'intermediate': '0',
#             'minor': '0'
#         }
#         self.SelectionDetails = None
#         """@ivar: Holds the SelectionDetails WSDL object that includes tracking type and value."""
# 
#         # Set Default as None. 'INCLUDE_DETAILED_SCANS' or None
#         self.ProcessingOptions = None
#         """@ivar: Holds the TrackRequestProcessingOptionType WSDL object that defaults no None."""
# 
#         # Call the parent FedexBaseService class for basic setup work.
#         super(FedexTrackRequest, self).__init__(
#                 self._config_obj, 'TrackService_v16.wsdl', *args, **kwargs)
#         self.IncludeDetailedScans = False
# 
#     def _prepare_wsdl_objects(self):
#         """
#         This sets the package identifier information. This may be a tracking
#         number or a few different things as per the Fedex spec.
#         """
# 
#         self.SelectionDetails = self.client.factory.create('TrackSelectionDetail')
# 
#         # Default to Fedex
#         self.SelectionDetails.CarrierCode = 'FDXE'
# 
#         track_package_id = self.client.factory.create('TrackPackageIdentifier')
# 
#         # Default to tracking number.
#         track_package_id.Type = 'TRACKING_NUMBER_OR_DOORTAG'
# 
#         self.SelectionDetails.PackageIdentifier = track_package_id
# 
#     def _check_response_for_request_errors(self):
#         """
#         Checks the response to see if there were any errors specific to
#         this WSDL.
#         """
#         if self.response.HighestSeverity == "ERROR":  # pragma: no cover
#             for notification in self.response.Notifications:
#                 if notification.Severity == "ERROR":
#                     if "Invalid tracking number" in notification.Message:
#                         raise FedexInvalidTrackingNumber(
#                                 notification.Code, notification.Message)
#                     else:
#                         raise FedexError(notification.Code, notification.Message)
# 
#     def _assemble_and_send_request(self):
#         """
#         Fires off the Fedex request.
#         
#         @warning: NEVER CALL THIS METHOD DIRECTLY. CALL send_request(), WHICH RESIDES
#             ON FedexBaseService AND IS INHERITED.
#         """
# 
#         client = self.client
#         # Fire off the query.
#         return client.service.track(
#                 WebAuthenticationDetail=self.WebAuthenticationDetail,
#                 ClientDetail=self.ClientDetail,
#                 TransactionDetail=self.TransactionDetail,
#                 Version=self.VersionId,
#                 SelectionDetails=self.SelectionDetails,
#                 ProcessingOptions=self.ProcessingOptions)


import unittest
import logging
import sys
from fedex.services.track_service import FedexTrackRequest
from tests.common import get_fedex_config
"""
Test module for the Fedex TrackService WSDL.
"""


sys.path.insert(0, '..')

# Common global config object for testing.

CONFIG_OBJ = get_fedex_config()

logging.getLogger('suds').setLevel(logging.ERROR)
logging.getLogger('fedex').setLevel(logging.INFO)


@unittest.skipIf(not CONFIG_OBJ.account_number, "No credentials provided.")
class TrackServiceTests(unittest.TestCase):
    """
    These tests verify that the shipping service WSDL is in good shape.
    """

    def test_track(self):
        # Test shipment tracking. Query for a tracking number and make sure the
        # first (and hopefully only) result matches up.

        tracking_num = '781820562774'


# Path: fedex/services/track_service.py
# class FedexTrackRequest(FedexBaseService):
#     """
#     This class allows you to track shipments by providing a tracking
#     number or other identifying features. By default, you
#     can simply pass a tracking number to the constructor. If you would like
#     to query shipments based on something other than tracking number, you will
#     want to read the documentation for the L{__init__} method. 
#     Particularly, the tracking_value and package_identifier arguments.
#     """
# 
#     def __init__(self, config_obj, *args, **kwargs):
#         """
#         Sends a shipment tracking request. The optional keyword args
#         detailed on L{FedexBaseService} apply here as well.
#         
#         @type config_obj: L{FedexConfig}
#         @param config_obj: A valid FedexConfig object.
#         """
# 
#         self._config_obj = config_obj
# 
#         # Holds version info for the VersionId SOAP object.
#         self._version_info = {
#             'service_id': 'trck',
#             'major': '16',
#             'intermediate': '0',
#             'minor': '0'
#         }
#         self.SelectionDetails = None
#         """@ivar: Holds the SelectionDetails WSDL object that includes tracking type and value."""
# 
#         # Set Default as None. 'INCLUDE_DETAILED_SCANS' or None
#         self.ProcessingOptions = None
#         """@ivar: Holds the TrackRequestProcessingOptionType WSDL object that defaults no None."""
# 
#         # Call the parent FedexBaseService class for basic setup work.
#         super(FedexTrackRequest, self).__init__(
#                 self._config_obj, 'TrackService_v16.wsdl', *args, **kwargs)
#         self.IncludeDetailedScans = False
# 
#     def _prepare_wsdl_objects(self):
#         """
#         This sets the package identifier information. This may be a tracking
#         number or a few different things as per the Fedex spec.
#         """
# 
#         self.SelectionDetails = self.client.factory.create('TrackSelectionDetail')
# 
#         # Default to Fedex
#         self.SelectionDetails.CarrierCode = 'FDXE'
# 
#         track_package_id = self.client.factory.create('TrackPackageIdentifier')
# 
#         # Default to tracking number.
#         track_package_id.Type = 'TRACKING_NUMBER_OR_DOORTAG'
# 
#         self.SelectionDetails.PackageIdentifier = track_package_id
# 
#     def _check_response_for_request_errors(self):
#         """
#         Checks the response to see if there were any errors specific to
#         this WSDL.
#         """
#         if self.response.HighestSeverity == "ERROR":  # pragma: no cover
#             for notification in self.response.Notifications:
#                 if notification.Severity == "ERROR":
#                     if "Invalid tracking number" in notification.Message:
#                         raise FedexInvalidTrackingNumber(
#                                 notification.Code, notification.Message)
#                     else:
#                         raise FedexError(notification.Code, notification.Message)
# 
#     def _assemble_and_send_request(self):
#         """
#         Fires off the Fedex request.
#         
#         @warning: NEVER CALL THIS METHOD DIRECTLY. CALL send_request(), WHICH RESIDES
#             ON FedexBaseService AND IS INHERITED.
#         """
# 
#         client = self.client
#         # Fire off the query.
#         return client.service.track(
#                 WebAuthenticationDetail=self.WebAuthenticationDetail,
#                 ClientDetail=self.ClientDetail,
#                 TransactionDetail=self.TransactionDetail,
#                 Version=self.VersionId,
#                 SelectionDetails=self.SelectionDetails,
#                 ProcessingOptions=self.ProcessingOptions)


# Path: tests/test_track_service.py
import unittest
import logging
import sys
from fedex.services.track_service import FedexTrackRequest
from tests.common import get_fedex_config

"""
Test module for the Fedex TrackService WSDL.
"""


sys.path.insert(0, '..')

# Common global config object for testing.

CONFIG_OBJ = get_fedex_config()

logging.getLogger('suds').setLevel(logging.ERROR)
logging.getLogger('fedex').setLevel(logging.INFO)


@unittest.skipIf(not CONFIG_OBJ.account_number, "No credentials provided.")
class TrackServiceTests(unittest.TestCase):
    """
    These tests verify that the shipping service WSDL is in good shape.
    """

    def test_track(self):
        # Test shipment tracking. Query for a tracking number and make sure the
        # first (and hopefully only) result matches up.

        tracking_num = '781820562774'


        track = FedexTrackRequest(CONFIG_OBJ)