Changeset View
Changeset View
Standalone View
Standalone View
swh/fuse/tests/conftest.py
Show All 19 Lines | |||||
@pytest.fixture | @pytest.fixture | ||||
def web_api_mock(requests_mock): | def web_api_mock(requests_mock): | ||||
for api_call, data in MOCK_ARCHIVE.items(): | for api_call, data in MOCK_ARCHIVE.items(): | ||||
# Convert Python dict JSON into a string (only for non-raw API call) | # Convert Python dict JSON into a string (only for non-raw API call) | ||||
if not api_call.endswith("raw/") and not api_call.startswith("graph/"): | if not api_call.endswith("raw/") and not api_call.startswith("graph/"): | ||||
data = json.dumps(data) | data = json.dumps(data) | ||||
# TODO: change headers to mock streaming graph/ API | |||||
http_method = requests_mock.get | http_method = requests_mock.get | ||||
if api_call.startswith("origin/") and api_call.endswith("get/"): | if api_call.startswith("origin/") and api_call.endswith("get/"): | ||||
http_method = requests_mock.head | http_method = requests_mock.head | ||||
http_method(f"{API_URL}/{api_call}", text=data) | http_method(f"{API_URL}/{api_call}", text=data) | ||||
return requests_mock | return requests_mock | ||||
▲ Show 20 Lines • Show All 46 Lines • Show Last 20 Lines |