Beispiel #1
0
def test_client_fail():
    client = Client('wrong', 'creds', 'for', 'ivoy', 'api', 'validation')
    try:
        client.init_tokens()
    except exc.InvalidInformation as ivoy_exc:
        assert ivoy_exc.code == -192
        assert ivoy_exc.message == 'Invalid Information Provided'
Beispiel #2
0
def test_budget_create():
    client = Client()
    info = order_info()
    budget = client.budget.create(info['addresses'])
    assert budget
    assert type(budget) == Budget
    assert budget.price
Beispiel #3
0
def test_waybill_by_ivoy_guide():
    client = Client()
    resp = client.waybill.download(ivoy_guide_list=['000303389P000040868'])
    assert resp
    assert type(resp) == Waybill
    assert resp.ivoy_guide_list == ['000303389P000040868']
    assert resp.byte_content
Beispiel #4
0
def test_waybill_by_id():
    client = Client()
    resp = client.waybill.download(id_package_list=[40868])
    assert resp
    assert type(resp) == Waybill
    assert resp.id_package_list == [40868]
    assert resp.byte_content
def test_location_sharing_no_messenger_location():
    with pytest.raises(IvoyException):
        client = Client()
        location_sharing = client.carrier_location.get_location(9502058)
        assert client
        assert IvoyException.code == -999
        assert location_sharing is None
Beispiel #6
0
def test_order_retrieve_http_500_error():
    client = Client()
    info = order_info()

    with pytest.raises(HTTPError) as ex:
        client.order.create(info['addresses'], info['package'],
                            info['payment'])
    assert ex.value.response.status_code == 500
Beispiel #7
0
def test_waybill_no_info():
    client = Client()
    try:
        client.waybill.download()
    except ValueError:
        pass
    else:
        assert False
def test_location_sharing_failed():
    with pytest.raises(IvoyException):
        client = Client()
        location_sharing = client.carrier_location.get_location(123)
        assert client
        assert IvoyException.code == -111
        assert location_sharing is None
        assert IvoyException.message == 'Invalid Information Provided'
def test_location_sharing_success():
    client = Client()
    location_sharing = client.carrier_location.get_location(1502057)
    assert client
    assert type(location_sharing) == CarrierLocation
    assert location_sharing.id == 1502057
    assert type(location_sharing.latitude) == float
    assert type(location_sharing.longitude) == float
Beispiel #10
0
def test_budget_create_fail():
    client = Client()
    bad_addresses = order_info()['bad_addresses']
    try:
        client.budget.create(bad_addresses)
    except NotEnoughAddresses as e:
        assert e.code == -111
        assert client
Beispiel #11
0
def test_order_create():
    client = Client()
    info = order_info()
    order = client.order.create(info['addresses'], info['package'],
                                info['payment'])
    assert order
    assert type(order) == Order
    assert order.id
Beispiel #12
0
def test_order_create_fail():
    client = Client()
    info = order_info()
    try:
        client.order.create(info['bad_addresses'], info['package'],
                            info['payment'])
    except exc.NotEnoughAddresses as e:
        assert client
        assert e.code == -111
def test_order_sharing_fail():
    client = Client()
    order_sharing = None
    try:
        order_sharing = client.order_sharing.get_tracking_url(2883031)
    except IvoyException as e:
        assert client
        assert e.code == -283
        assert order_sharing is None
Beispiel #14
0
def test_order_cancel_fail():
    client = Client()
    order = None
    try:
        order = client.order.cancel('wrong')
    except exc.IvoyException as e:
        assert client
        assert e.code == -100
        assert order is None
Beispiel #15
0
def test_package_retrieve():
    client = Client()
    resp = client.package.retrieve(40871)
    assert resp
    assert type(resp) == Package
    assert resp.package_list[0].id == 40871
    assert resp.package_list[0].ivoy_guide
    assert resp.package_list[0].price
    assert type(resp.package_list[0].package_type) == PackageType
Beispiel #16
0
def test_to_object_wrong_comes_from():
    client = Client()
    info = package_info()
    try:
        client.package._to_object(info.to_dict(), comes_from='wrong')
    except ValueError:
        pass
    else:
        assert False
def test_order_sharing():
    client = Client()
    order_sharing = client.order_sharing.get_tracking_url(2883031)
    assert client
    assert order_sharing
    assert type(order_sharing) == OrderSharing
    assert order_sharing.id == 2883031
    assert (order_sharing.tracking_url ==
            'https://v2.ivoy.mx/client/app/share/Mjg4MzAzMWk=')
Beispiel #18
0
def test_package_create():
    client = Client()
    info = package_info()
    resp = client.package.create([info])
    assert resp
    assert type(resp) == Package
    assert resp.package_list[0].id
    assert resp.package_list[0].ivoy_guide
    assert resp.package_list[0].price
    assert type(resp.package_list[0].package_type) == PackageType
Beispiel #19
0
def test_order_create_bad_phone_number():
    client = Client()
    info = order_info()
    try:
        client.order.create(info['addresses'], info['package'],
                            info['payment'])
    except exc.InvalidPhone as e:
        assert client
        assert e.code == -101
        assert e.message == 'Invalid or incomplete Phone Number'
Beispiel #20
0
def test_not_available():
    client = Client()
    info = order_info()
    try:
        client.order.create(info['addresses'], info['package'],
                            info['payment'])
    except exc.NotAvailable as e:
        assert client
        assert e.code == -160
        assert e.message == 'System Not Available, try again later'
Beispiel #21
0
def test_already_exists():
    client = Client()
    info = order_info()
    try:
        client.order.create(info['addresses'], info['package'],
                            info['payment'])
    except exc.AlreadyExists as e:
        assert client
        assert e.code == -208
        assert e.message == 'User with this information already exists'
Beispiel #22
0
def test_invalid_vehicle():
    client = Client()
    info = order_info()
    try:
        client.order.create(info['addresses'], info['package'],
                            info['payment'])
    except exc.InvalidVehicle as e:
        assert client
        assert e.code == -258
        assert e.message == 'Error on vehicle or not available'
Beispiel #23
0
def test_missing_incomplete_information():
    client = Client()
    info = order_info()
    try:
        client.order.create(info['addresses'], info['package'],
                            info['payment'])
    except exc.MissingInformation as e:
        assert client
        assert e.code == -199
        assert e.message == 'Incomplete or missing information'
Beispiel #24
0
def test_insufficient_founds():
    client = Client()
    info = order_info()
    try:
        client.order.create(info['addresses'], info['package'],
                            info['payment'])
    except exc.InsufficientFunds as e:
        assert client
        assert e.code == -139
        assert e.message == 'Insufficient Founds'
Beispiel #25
0
def test_unable_to_create():
    client = Client()
    info = order_info()
    try:
        client.order.create(info['addresses'], info['package'],
                            info['payment'])
    except exc.UnableToCreate as e:
        assert client
        assert e.code == -251
        assert e.message == 'Unable to create or process try again later'
Beispiel #26
0
def test_invalid_date():
    client = Client()
    info = order_info()
    try:
        client.order.create(info['addresses'], info['package'],
                            info['payment'])
    except exc.InvalidDate as e:
        assert client
        assert e.code == -112
        assert e.message == 'Invalid date try a different date'
Beispiel #27
0
def test_out_of_range():
    client = Client()
    info = order_info()
    try:
        client.order.create(info['addresses'], info['package'],
                            info['payment'])
    except exc.OutOFRange as e:
        assert client
        assert e.code == -114
        assert e.message == 'Address is out of range'
Beispiel #28
0
def test_invalid_code():
    client = Client()
    info = order_info()
    try:
        client.order.create(info['addresses'], info['package'],
                            info['payment'])
    except exc.InvalidCode as e:
        assert client
        assert e.code == -124
        assert e.message == 'This code is not valid or already used'
Beispiel #29
0
def test_order_cancel():
    client = Client()
    info = order_info()
    order_created = client.order.create(info['addresses'], info['package'],
                                        info['payment'])
    order = client.order.cancel(order_created.id)
    assert order
    assert type(order) == Order
    assert order.order_status == OrderStatus.cancelled_by_customer
    assert order.id == order_created.id
Beispiel #30
0
def test_invoice_error():
    client = Client()
    info = order_info()
    try:
        client.order.create(info['addresses'], info['package'],
                            info['payment'])
    except exc.InvoiceError as e:
        assert client
        assert e.code == -157
        assert e.message == 'Invoice cannot be created for this order'