示例#1
0
 def test_track_fedex(self):
     p = Package('012345678901234')
     try:
         p.track()
     except NotImplementedError:
         pass
     else:
         raise AssertionError('tracking fedex package should fail')
示例#2
0
 def test_track_fedex(self):
     p = Package('012345678901234')
     try:
         p.track()
     except NotImplementedError:
         pass
     else:
         raise AssertionError('tracking fedex package should fail')
示例#3
0
def track_shipment(shipment):
    """Receives a shipment object. Returns a dictionary of activities.

    activities = { 'shipment.id': [ {activity}, {activity} ] }"""

    activities = {}
    p = Package(shipment.tracking_no)
    activity_entries = p.track()
    activities[shipment.id] = activity_entries
    return activities
示例#4
0
def track_shipment(shipment):
    """Receives a shipment object. Returns a dictionary of activities.

    activities = { 'shipment.id': [ {activity}, {activity} ] }"""

    activities = {}
    p = Package(shipment.tracking_no)
    activity_entries = p.track()
    activities[shipment.id] = activity_entries
    return activities
示例#5
0
 def test_track_ups(self):
     if not packagetrack.config.has_section('UPS'):
         raise SkipTest
     # This is just a random tracking number found on google. To find more,
     # google for something like:
     # ["Tracking Detail" site:wwwapps.ups.com inurl:WebTracking]
     p = Package('1Z58R4770350434926')
     info = p.track()
     assert info.status != ''
     assert isinstance(info.delivery_date, date)
     assert isinstance(info.last_update, datetime)
示例#6
0
 def test_track_ups(self):
     if not packagetrack.config.has_section('UPS'):
         raise SkipTest
     # This is just a random tracking number found on google. To find more,
     # google for something like:
     # ["Tracking Detail" site:wwwapps.ups.com inurl:WebTracking]
     p = Package('1Z12345E0291980793')
     info = p.track()
     assert info.status != ''
     assert isinstance(info.delivery_date, date)
     assert isinstance(info.last_update, datetime)
示例#7
0
def request_email_body(messages):
    """Receives a list of dictionaries of message id's.
    Returns a dictionary of tracking numbers."""

    for email in messages:
        url = "https://www.googleapis.com/gmail/v1/users/%s/messages/%s" % (session.get('user_email'), email["id"])
        response = gmail.get(url)
        base64url_encoded_string = response.data["payload"]["body"]["data"]
        decoded = base64.b64decode(base64url_encoded_string.replace('-', '/')).replace('_', '+')
        tracking_number = parse_tracking_number(decoded)
        p = Package(tracking_number)
        return p.url()
示例#8
0
def track():
    tracking_number = request.args.get('tn', '')
    if not tracking_number:
        return redirect(url_for('index'))
    p = Package(tracking_number)
    status_list = p.track()
    locations = [email_helper.parse_location_no_save(loc) for loc in status_list]
    cities = ['{city}, {state}'.format(city=loc.get('city'), state=loc.get('state')) for loc in locations if loc.get('city') is not None and loc.get('state') is not None]
    return render_template("track.html",
                           shipment=p,
                           locations=locations,
                           cities=json.dumps(cities),
                           GOOGLE_MAPS=app.config.get('GOOGLE_MAPS'))
示例#9
0
 def test_track_unknown(self):
     try:
         Package('12391241248').track()
     except UnsupportedShipper:
         pass
     else:
         raise AssertionError("tracking package with unknown "
                              "shipper should fail")
示例#10
0
 def test_ups_url(self):
     num = '1Z9999999999999999'
     url = Package(num).url()
     assert num in url
     assert url.startswith('http')
示例#11
0
 def test_usps_url(self):
     num = '91124235'
     url = Package(num).url()
     assert num in url
     assert url.startswith('http')
示例#12
0
 def test_identify_unknown(self):
     assert Package('14324423523').shipper == None
示例#13
0
 def test_fedex_url(self):
     num = '012345678901234'
     url = Package(num).url()
     assert num in url
     assert url.startswith('http')
示例#14
0
 def test_identify_usps(self):
     assert Package('91124235').shipper == 'USPS'
示例#15
0
 def test_identify_fedex(self):
     assert Package('012345678901234').shipper == 'FedEx'
示例#16
0
 def test_fedex_url(self):
     num = '012345678901234'
     url = Package(num).url()
     assert num in url
     assert url.startswith('http')
示例#17
0
 def test_usps_url(self):
     num = '91124235'
     url = Package(num).url()
     assert num in url
     assert url.startswith('http')
示例#18
0
 def test_ups_url(self):
     num = '1Z9999999999999999'
     url = Package(num).url()
     assert num in url
     assert url.startswith('http')
示例#19
0
 def test_identify_ups(self):
     assert Package('1Z9999999999999999').shipper == 'UPS'
示例#20
0
 def test_validate_ups(self):
     assert Package('1Z58R4770350889570').validate()
     assert not Package('1Z58R4770350889572').validate()
示例#21
0
 def test_usps_validate(self):
     assert Package('9405503699300451135169').validate()
     assert not Package('9405503699300451134169').validate()