Skip to content

Commit 15b0e48

Browse files
committed
Test out new keyword.
1 parent 5924584 commit 15b0e48

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/integration/test_orders_api.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
TEST_DOWNLOAD_ACTUAL_URL = f'{TEST_URL}/download_actual'
3636
TEST_ORDERS_URL = f'{TEST_URL}/orders/v2'
3737
TEST_STATS_URL = f'{TEST_URL}/stats/orders/v2'
38+
TEST_ORDER_NAME = 'my-order-name'
3839

3940
LOGGER = logging.getLogger(__name__)
4041

@@ -64,6 +65,7 @@ def f():
6465
'location': dl_url, 'name': 'file.json'
6566
},
6667
]
68+
order_description['name'] = TEST_ORDER_NAME
6769

6870
get_url = f'{TEST_ORDERS_URL}/{oid}'
6971
mock_resp = httpx.Response(HTTPStatus.OK, json=order_description)
@@ -853,3 +855,23 @@ async def test_download_order_overwrite_false_nonexisting_data(
853855
# Check that the was data downloaded and has the correct contents
854856
with open(Path(tmpdir, 'file.json')) as f:
855857
assert json.load(f) == downloaded_content
858+
859+
860+
@respx.mock
861+
@pytest.mark.anyio
862+
async def test_download_order_save_to_order_name(
863+
tmpdir, oid, session, create_download_mock, downloaded_content):
864+
"""
865+
Test if download_order() downloads data to a directory named after the
866+
given order name.
867+
"""
868+
869+
create_download_mock()
870+
cl = OrdersClient(session, base_url=TEST_URL)
871+
filenames = await cl.download_order(oid, save_to_order_name=True,
872+
directory=str(tmpdir))
873+
874+
assert filenames == [Path(tmpdir, TEST_ORDER_NAME, 'file.json')]
875+
# Check that the was data downloaded and has the correct contents
876+
with open(Path(tmpdir, TEST_ORDER_NAME, 'file.json')) as f:
877+
assert json.load(f) == downloaded_content

0 commit comments

Comments
 (0)