Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

accept licences in integration tests #41

Merged
merged 4 commits into from
Mar 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from typing import Any

import pytest
import requests


@pytest.fixture
Expand All @@ -12,9 +13,21 @@ def api_root_url() -> str:


@pytest.fixture
def api_key() -> str:
def api_key(api_root_url: str) -> str:
if key := os.getenv("CADS_API_KEY"):
return key

# default to test user 1
return os.getenv("CADS_API_KEY") or "00000000-0000-4000-a000-000000000000"
key = "00000000-0000-4000-a000-000000000000"

# Accept all licences
result = requests.get(f"{api_root_url}/catalogue/v1/vocabularies/licences")
requests.patch(
f"{api_root_url}/profiles/v1/account/licences",
json=result.json(),
headers={"PRIVATE-TOKEN": key},
)
return key


@pytest.fixture
Expand Down