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

Commit 6301fc1

Browse files
authored
run integration tests (#74)
* run integration tests * fix get_config test * raising=False * change all-tests * skip licence validation * fix doc tests
1 parent 3316bea commit 6301fc1

File tree

5 files changed

+21
-7
lines changed

5 files changed

+21
-7
lines changed

.github/workflows/on-push.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ jobs:
148148

149149
strategy:
150150
matrix:
151-
python-version: ['3.8', '3.9', '3.10', '3.12']
151+
python-version: ['3.8', '3.12']
152152
extra: ['-ci']
153153

154154
steps:
@@ -173,8 +173,10 @@ jobs:
173173
run: |
174174
python -m pip install --no-deps -e .
175175
- name: Run tests
176+
env:
177+
CADS_API_URL: ${{ secrets.CADS_API_URL }}
176178
run: |
177-
make unit-tests COV_REPORT=xml
179+
make all-tests COV_REPORT=xml
178180
179181
distribution:
180182
runs-on: ubuntu-latest

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ integration-tests:
3939
doc-tests:
4040
python -m pytest -vv --doctest-glob='*.md' README.md
4141

42-
all-tests: default integration-tests doc-tests
42+
all-tests: unit-tests integration-tests doc-tests

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@ it is designed to be the least performant option to access the system.
1212
Draft Python API:
1313

1414
```python
15+
>>> import os
16+
>>> anon_key = os.getenv("CADS_API_ANON_KEY", "00112233-4455-6677-c899-aabbccddeeff")
17+
1518
>>> import cads_api_client
16-
>>> client = cads_api_client.ApiClient()
19+
>>> client = cads_api_client.ApiClient(key=anon_key)
1720
>>> assert client.check_authentication()
1821

1922
>>> collection = client.collection("reanalysis-era5-pressure-levels")

tests/integration_test_40_api_client.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import datetime
55
import os
66
import pathlib
7+
import warnings
78
from typing import Any
89

910
import pytest
@@ -21,7 +22,12 @@ def api_anon_client(api_root_url: str, api_anon_key: str) -> ApiClient:
2122

2223

2324
def test_accept_licence() -> None:
24-
client = ApiClient(maximum_tries=0)
25+
with warnings.catch_warnings():
26+
warnings.simplefilter("ignore")
27+
client = ApiClient(maximum_tries=0)
28+
29+
if client.key is None:
30+
pytest.skip("The API key is missing")
2531

2632
licence = client.licences["licences"][0]
2733
licence_id = licence["id"]

tests/test_10_config.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,18 @@ def test_read_configuration_error(tmp_path: pathlib.Path) -> None:
3434
config.read_configuration_file("non-existent-file")
3535

3636

37-
def test_get_config_from_configuration_file(tmp_path: pathlib.Path) -> None:
37+
def test_get_config_from_configuration_file(
38+
tmp_path: pathlib.Path, monkeypatch: pytest.MonkeyPatch
39+
) -> None:
40+
monkeypatch.delenv("CADS_API_KEY", raising=False)
41+
monkeypatch.delenv("CADS_API_URL", raising=False)
3842
expected_config = {"url": "dummy-url", "key": "dummy-key"}
3943

4044
config_file = tmp_path / ".cads-api-client.json"
4145
with config_file.open("w") as fp:
4246
json.dump(expected_config, fp)
4347

4448
res = config.get_config("url", str(config_file))
45-
4649
assert res == expected_config["url"]
4750

4851
with pytest.raises(KeyError):

0 commit comments

Comments
 (0)