Skip to content

Commit 6898c25

Browse files
committed
Add mondialrelay_fr vcr tests
1 parent 605d0ee commit 6898c25

File tree

8 files changed

+2950
-7
lines changed

8 files changed

+2950
-7
lines changed

roulier/carriers/mondialrelay_fr/tests/__init__.py

Whitespace-only changes.

roulier/carriers/mondialrelay_fr/tests/cassettes/test_mondialrelay/test_mondialrelay_label.yaml

+908
Large diffs are not rendered by default.

roulier/carriers/mondialrelay_fr/tests/cassettes/test_mondialrelay/test_mondialrelay_label_return.yaml

+908
Large diffs are not rendered by default.

roulier/carriers/mondialrelay_fr/tests/cassettes/test_mondialrelay/test_mondialrelay_pickup_site.yaml

+1,047
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Copyright 2024 Akretion (http://www.akretion.com).
2+
# @author Florian Mounier <florian.mounier@akretion.com>
3+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
4+
5+
6+
from ....tests.conftest import * # noqa
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Copyright 2024 Akretion (http://www.akretion.com).
2+
# @author Florian Mounier <florian.mounier@akretion.com>
3+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
4+
5+
import pytest
6+
from roulier import roulier
7+
from ....helpers import merge
8+
9+
10+
@pytest.fixture
11+
def get_label_data(credentials, base_get_label_data):
12+
return merge(
13+
credentials["mondialrelay_fr"],
14+
base_get_label_data,
15+
{
16+
"service": {
17+
"product": "HOM",
18+
"pickupMode": "REL",
19+
"pickupSite": "AUTO",
20+
"pickupCountry": "FR",
21+
}
22+
},
23+
)
24+
25+
26+
@pytest.fixture
27+
def find_pickup_site_data(credentials, base_find_pickup_site_data):
28+
return merge(
29+
credentials["mondialrelay_fr"],
30+
base_find_pickup_site_data,
31+
)
32+
33+
34+
@pytest.mark.vcr()
35+
def test_mondialrelay_label(get_label_data):
36+
rv = roulier.get("mondialrelay_fr", "get_label", get_label_data)
37+
assert "parcels" in rv
38+
assert "label" in rv["parcels"][0]
39+
label = rv["parcels"][0]["label"]
40+
assert label["name"] == "label_url"
41+
assert label["type"] == "url"
42+
assert label["data"].startswith("https://www.mondialrelay.com")
43+
44+
45+
@pytest.mark.vcr()
46+
def test_mondialrelay_label_return(get_label_data):
47+
rv = roulier.get(
48+
"mondialrelay_fr",
49+
"get_label",
50+
merge(
51+
get_label_data,
52+
{
53+
"service": {
54+
"product": "LCC",
55+
},
56+
},
57+
),
58+
)
59+
assert "parcels" in rv
60+
assert "label" in rv["parcels"][0]
61+
label = rv["parcels"][0]["label"]
62+
assert label["name"] == "label_url"
63+
assert label["type"] == "url"
64+
assert label["data"].startswith("https://www.mondialrelay.com")
65+
66+
67+
@pytest.mark.vcr()
68+
def test_mondialrelay_pickup_site(find_pickup_site_data):
69+
rv = roulier.get("mondialrelay_fr", "find_pickup_site", find_pickup_site_data)
70+
assert "sites" in rv
71+
assert len(rv["sites"]) > 0
72+
assert "name" in rv["sites"][0]

roulier/tests/conftest.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212

1313
@pytest.fixture(scope="session")
1414
def credentials():
15-
return {
16-
**CREDENTIALS,
17-
"isTest": True,
18-
}
15+
for cred in CREDENTIALS.values():
16+
if "auth" in cred:
17+
cred["auth"]["isTest"] = True
18+
return CREDENTIALS
1919

2020

2121
@pytest.fixture

roulier/tests/credentials_demo.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
"""Copy this file to credentials.py and fill in your test credentials"""
66

77
CREDENTIALS = {
8-
"mondialrelay_fr": { # These are public test credentials
9-
"login": "BDTEST13",
10-
"password": "PrivateK",
8+
"mondialrelay_fr": {
9+
"auth": { # These are public test credentials
10+
"login": "BDTEST13",
11+
"password": "PrivateK",
12+
}
1113
},
1214
}

0 commit comments

Comments
 (0)