-
Notifications
You must be signed in to change notification settings - Fork 47
/
fixtures_storage.py
63 lines (49 loc) · 1.65 KB
/
fixtures_storage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import pytest
from up42.storage import Storage
from .fixtures_globals import (
API_HOST,
ASSET_ID,
JSON_ASSET,
JSON_ASSETS,
JSON_ORDER,
JSON_ORDERS,
JSON_STORAGE_STAC,
ORDER_ID,
PYSTAC_MOCK_CLIENT,
)
@pytest.fixture()
def storage_mock(auth_mock, requests_mock):
# pystac client authentication
url_pystac_client = f"{API_HOST}/v2/assets/stac"
requests_mock.get(url=url_pystac_client, json=PYSTAC_MOCK_CLIENT)
# assets
url_storage_assets = f"{API_HOST}/v2/assets"
requests_mock.get(url=url_storage_assets, json=JSON_ASSETS)
# storage stac
url_storage_stac = f"{API_HOST}/v2/assets/stac/search"
requests_mock.post(url=url_storage_stac, json=JSON_STORAGE_STAC)
# asset info
url_asset_info = f"{API_HOST}/v2/assets/{ASSET_ID}/metadata"
requests_mock.get(url=url_asset_info, json=JSON_ASSET)
# orders
url_storage_orders = (
f"{API_HOST}/v2/orders"
"?sort=createdAt,desc&workspaceId=workspace_id_123"
"&type=ARCHIVE&tags=project-7&tags=optical&size=50"
)
requests_mock.get(url=url_storage_orders, json=JSON_ORDERS)
url_storage_orders_params = (
f"{API_HOST}/v2/orders"
"?sort=createdAt,desc"
"&displayName=Test&type=ARCHIVE&status=FULFILLED&status=PLACED&size=50"
)
requests_mock.get(url=url_storage_orders_params, json=JSON_ORDERS)
# orders info
url_order_info = f"{API_HOST}/v2/orders/{ORDER_ID}"
requests_mock.get(url=url_order_info, json=JSON_ORDER)
storage = Storage(auth=auth_mock)
return storage
@pytest.fixture()
def storage_live(auth_live):
storage = Storage(auth=auth_live)
return storage