Skip to content

Commit

Permalink
Add mondialrelay_fr vcr tests
Browse files Browse the repository at this point in the history
  • Loading branch information
paradoxxxzero committed Sep 16, 2024
1 parent 605d0ee commit 6898c25
Show file tree
Hide file tree
Showing 8 changed files with 2,950 additions and 7 deletions.
Empty file.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions roulier/carriers/mondialrelay_fr/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Copyright 2024 Akretion (http://www.akretion.com).
# @author Florian Mounier <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).


from ....tests.conftest import * # noqa
72 changes: 72 additions & 0 deletions roulier/carriers/mondialrelay_fr/tests/test_mondialrelay.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Copyright 2024 Akretion (http://www.akretion.com).
# @author Florian Mounier <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import pytest
from roulier import roulier
from ....helpers import merge


@pytest.fixture
def get_label_data(credentials, base_get_label_data):
return merge(
credentials["mondialrelay_fr"],
base_get_label_data,
{
"service": {
"product": "HOM",
"pickupMode": "REL",
"pickupSite": "AUTO",
"pickupCountry": "FR",
}
},
)


@pytest.fixture
def find_pickup_site_data(credentials, base_find_pickup_site_data):
return merge(
credentials["mondialrelay_fr"],
base_find_pickup_site_data,
)


@pytest.mark.vcr()
def test_mondialrelay_label(get_label_data):
rv = roulier.get("mondialrelay_fr", "get_label", get_label_data)
assert "parcels" in rv
assert "label" in rv["parcels"][0]
label = rv["parcels"][0]["label"]
assert label["name"] == "label_url"
assert label["type"] == "url"
assert label["data"].startswith("https://www.mondialrelay.com")


@pytest.mark.vcr()
def test_mondialrelay_label_return(get_label_data):
rv = roulier.get(
"mondialrelay_fr",
"get_label",
merge(
get_label_data,
{
"service": {
"product": "LCC",
},
},
),
)
assert "parcels" in rv
assert "label" in rv["parcels"][0]
label = rv["parcels"][0]["label"]
assert label["name"] == "label_url"
assert label["type"] == "url"
assert label["data"].startswith("https://www.mondialrelay.com")


@pytest.mark.vcr()
def test_mondialrelay_pickup_site(find_pickup_site_data):
rv = roulier.get("mondialrelay_fr", "find_pickup_site", find_pickup_site_data)
assert "sites" in rv
assert len(rv["sites"]) > 0
assert "name" in rv["sites"][0]
8 changes: 4 additions & 4 deletions roulier/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@

@pytest.fixture(scope="session")
def credentials():
return {
**CREDENTIALS,
"isTest": True,
}
for cred in CREDENTIALS.values():
if "auth" in cred:
cred["auth"]["isTest"] = True
return CREDENTIALS


@pytest.fixture
Expand Down
8 changes: 5 additions & 3 deletions roulier/tests/credentials_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
"""Copy this file to credentials.py and fill in your test credentials"""

CREDENTIALS = {
"mondialrelay_fr": { # These are public test credentials
"login": "BDTEST13",
"password": "PrivateK",
"mondialrelay_fr": {
"auth": { # These are public test credentials
"login": "BDTEST13",
"password": "PrivateK",
}
},
}

0 comments on commit 6898c25

Please sign in to comment.