Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update pre-commit, new pooch for new zenodo API #86

Merged
merged 4 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ repos:
- id: detect-private-key
- id: mixed-line-ending
- repo: https://github.com/psf/black
rev: '23.9.1'
rev: '23.10.0'
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
Expand All @@ -41,7 +41,7 @@ repos:
hooks:
- id: blacken-docs
- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v1.5.1'
rev: 'v1.6.1'
hooks:
- id: mypy
additional_dependencies:
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ install_requires =
pandas
treelib
requests
pooch
pooch >= 1.8.0
pyarrow

[options.extras_require]
Expand Down
25 changes: 24 additions & 1 deletion unfccc_di_api/tests/test_unfccc_di_api.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for the `unfccc_di_api` package."""
import os

import pytest

Expand All @@ -16,7 +17,18 @@ def zenodo_reader() -> ZenodoReader:
return ZenodoReader()


@pytest.fixture(scope="module", params=["unfccc", "zenodo"])
@pytest.fixture(
scope="module",
params=[
pytest.param(
"unfccc",
marks=pytest.mark.skipif(
"GITHUB_ACTIONS" not in os.environ, reason="UNFCCC reader not available"
),
),
"zenodo",
],
)
def reader(request):
if request.param == "unfccc":
return UNFCCCApiReader()
Expand All @@ -31,6 +43,12 @@ def test_not_implemented(zenodo_reader):
zenodo_reader.query(party_code="DEU", normalize_gas_names=False)


def test_query(reader):
res = reader.query(party_code="DEU")
assert len(res) > 0


@pytest.mark.skip(reason="UNFCCC reader not available")
def test_non_annex_one(api_reader):
ans = api_reader.non_annex_one_reader.query(party_codes=["MMR"])

Expand All @@ -41,6 +59,7 @@ def test_non_annex_one(api_reader):
assert len(ans) > 1


@pytest.mark.skip(reason="UNFCCC reader not available")
def test_annex_one(api_reader: UNFCCCApiReader):
ans = api_reader.annex_one_reader.query(party_codes=["DEU"], gases=["N₂O"])
assert len(ans) > 1
Expand All @@ -55,11 +74,13 @@ def test_unified(reader):
reader.query(party_code="ASDF")


@pytest.mark.skip(reason="UNFCCC reader not available")
def test_unified_gases(api_reader: UNFCCCApiReader):
ans = api_reader.query(party_code="DEU", gases=["N₂O"])
assert len(ans) > 1


@pytest.mark.skip(reason="UNFCCC reader not available")
@pytest.mark.parametrize("normalize", [True, False])
def test_unified_as_ascii(api_reader: UNFCCCApiReader, normalize: bool):
# assert that using standardized string ('N2O' instead of "N₂O") works
Expand All @@ -70,6 +91,7 @@ def test_unified_as_ascii(api_reader: UNFCCCApiReader, normalize: bool):
assert ans.gas.unique()[0] == ("N2O" if normalize else "N₂O")


@pytest.mark.skip(reason="UNFCCC reader not available")
@pytest.mark.parametrize("category_id", [9559, 9608])
def test_category_filter(api_reader: UNFCCCApiReader, category_id):
# this failed due to duplicate variableIds
Expand All @@ -80,6 +102,7 @@ def test_category_filter(api_reader: UNFCCCApiReader, category_id):
assert len(df["category"].unique()) == 1


@pytest.mark.skip(reason="UNFCCC reader not available")
def test_no_data(api_reader: UNFCCCApiReader):
with pytest.raises(unfccc_di_api.NoDataError):
api_reader.annex_one_reader.query(party_codes=["FIN"], category_ids=[14817])
Loading