def test_ect_tracking_ok(): p = Trackr.track('ect', 'PN871429404BR') assert isinstance(p, Package) assert p.object_id == 'PN871429404BR' for t in p.tracking_info: assert isinstance(t, TrackingInfo)
def test_fake_tracking_single_object(): p = Trackr.track('fake', 'SX123456789BR') assert isinstance(p, Package) assert p.object_id == 'SX123456789BR' for t in p.tracking_info: assert isinstance(t, TrackingInfo)
def test_ect_tracking_bulk_ok(): object_ids = [ 'PO454515464BR', 'OA473577210BR', 'OA468082105BR', ] items = Trackr.track( 'ect', object_ids, ) for i, item in enumerate(items): assert item.object_id == object_ids[i]
def test_ect_tracking_bulk_missing_object(): object_ids = [ 'PO454515464BR', # missing 'OA473577210BR', 'OA468082105BR', ] items = Trackr.track( 'ect', object_ids, ) assert len(items) == 2 for i, item in enumerate(items): assert item.object_id == object_ids[i + 1]
def main(carrier, object_id): from trackr import Trackr from trackr.exceptions import PackageNotFound try: p = Trackr.track(carrier, object_id) except PackageNotFound as e: click.echo( click.style(u'Package with object ID {} ({}) not found'.format( object_id, carrier), fg='red')) if e.carrier_message: click.echo( click.style( u'Carrier message: {}'.format(e.carrier_message), fg='red', )) return click.echo(click.style(u'Package found!', fg='green')) for t in p.tracking_info: click.echo(t.__unicode__())
def test_ect_tracking_not_found(): with pytest.raises(PackageNotFound) as exc_info: Trackr.track('ect', 'SX123456789BR') assert exc_info.value.object_id == 'SX123456789BR'
def test_fake_tracking_bulk(): with pytest.raises(NotImplementedError): Trackr.track('fake', ['1', '2'])