|
35 | 35 | TEST_DOWNLOAD_ACTUAL_URL = f'{TEST_URL}/download_actual'
|
36 | 36 | TEST_ORDERS_URL = f'{TEST_URL}/orders/v2'
|
37 | 37 | TEST_STATS_URL = f'{TEST_URL}/stats/orders/v2'
|
| 38 | +TEST_ORDER_NAME = 'my-order-name' |
38 | 39 |
|
39 | 40 | LOGGER = logging.getLogger(__name__)
|
40 | 41 |
|
@@ -64,6 +65,7 @@ def f():
|
64 | 65 | 'location': dl_url, 'name': 'file.json'
|
65 | 66 | },
|
66 | 67 | ]
|
| 68 | + order_description['name'] = TEST_ORDER_NAME |
67 | 69 |
|
68 | 70 | get_url = f'{TEST_ORDERS_URL}/{oid}'
|
69 | 71 | mock_resp = httpx.Response(HTTPStatus.OK, json=order_description)
|
@@ -853,3 +855,23 @@ async def test_download_order_overwrite_false_nonexisting_data(
|
853 | 855 | # Check that the was data downloaded and has the correct contents
|
854 | 856 | with open(Path(tmpdir, 'file.json')) as f:
|
855 | 857 | 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