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

enabled tests with secrets #741

Merged
merged 4 commits into from
Jan 24, 2024
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: 4 additions & 0 deletions .github/workflows/pytest-py312.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ jobs:
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
env:
CDSAPI_KEY: ${{ secrets.CDSAPI_KEY }}
COPERNICUS_MARINE_SERVICE_USERNAME: ${{ secrets.COPERNICUS_MARINE_SERVICE_USERNAME }}
COPERNICUS_MARINE_SERVICE_PASSWORD: ${{ secrets.COPERNICUS_MARINE_SERVICE_PASSWORD }}
run: |
pytest -m "not requireslocaldata" --cov=dfm_tools --cov-report xml --cov-report term
- uses: codecov/codecov-action@v1
4 changes: 4 additions & 0 deletions .github/workflows/pytest-py313.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ jobs:
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
env:
CDSAPI_KEY: ${{ secrets.CDSAPI_KEY }}
COPERNICUS_MARINE_SERVICE_USERNAME: ${{ secrets.COPERNICUS_MARINE_SERVICE_USERNAME }}
COPERNICUS_MARINE_SERVICE_PASSWORD: ${{ secrets.COPERNICUS_MARINE_SERVICE_PASSWORD }}
run: |
pytest -m "not requireslocaldata" --cov=dfm_tools --cov-report xml --cov-report term
- uses: codecov/codecov-action@v1
4 changes: 4 additions & 0 deletions .github/workflows/pytest-py39-mindeps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ jobs:
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
env:
CDSAPI_KEY: ${{ secrets.CDSAPI_KEY }}
COPERNICUS_MARINE_SERVICE_USERNAME: ${{ secrets.COPERNICUS_MARINE_SERVICE_USERNAME }}
COPERNICUS_MARINE_SERVICE_PASSWORD: ${{ secrets.COPERNICUS_MARINE_SERVICE_PASSWORD }}
run: |
pytest -m "not requireslocaldata" --cov=dfm_tools --cov-report xml --cov-report term
- uses: codecov/codecov-action@v1
4 changes: 4 additions & 0 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ jobs:
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
env:
CDSAPI_KEY: ${{ secrets.CDSAPI_KEY }}
COPERNICUS_MARINE_SERVICE_USERNAME: ${{ secrets.COPERNICUS_MARINE_SERVICE_USERNAME }}
COPERNICUS_MARINE_SERVICE_PASSWORD: ${{ secrets.COPERNICUS_MARINE_SERVICE_PASSWORD }}
run: |
pytest -m "not requireslocaldata" --cov=dfm_tools --cov-report xml --cov-report term
- uses: codecov/codecov-action@v1
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ markers = [
"systemtest: mark a test as systemtest. Used for testing at a higher level, verifying a given input returns the expected output",
"acceptance: mark a test as acceptance. Used for non-functional requirements and data that needs to be human-verified",
"requireslocaldata: mark a test that cannot run on Github",
"requiressecrets: mark a test that requires environment variables to be set (e.g. via Github secrets)",
]

[tool.flake8]
Expand Down
14 changes: 5 additions & 9 deletions tests/test_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import dfm_tools as dfmt


@pytest.mark.requireslocaldata
@pytest.mark.requiressecrets
@pytest.mark.unittest
def test_cds_credentials():
# check if the credentials are present on this system
Expand All @@ -23,15 +23,13 @@ def test_cds_credentials():
assert "CDSAPI_URL" in os.environ.keys()


#TODO: properly set environment variables in github would prevent localness
@pytest.mark.requireslocaldata
@pytest.mark.requiressecrets
@pytest.mark.unittest
def test_copernicusmarine_credentials():
copernicusmarine_credentials()


#TODO: properly set environment variables in github would prevent localness
@pytest.mark.requireslocaldata
@pytest.mark.requiressecrets
@pytest.mark.unittest
def test_download_era5(tmp_path):
date_min = '2010-01-01'
Expand All @@ -45,8 +43,7 @@ def test_download_era5(tmp_path):
dir_output=tmp_path, overwrite=True)


#TODO: properly set environment variables in github would prevent localness
@pytest.mark.requireslocaldata
@pytest.mark.requiressecrets
@pytest.mark.unittest
def test_download_cmems_my(tmp_path):
date_min = '2010-01-01'
Expand All @@ -61,8 +58,7 @@ def test_download_cmems_my(tmp_path):
dir_output=tmp_path, file_prefix=file_prefix, overwrite=True)


#TODO: properly set environment variables in github would prevent localness
@pytest.mark.requireslocaldata
@pytest.mark.requiressecrets
@pytest.mark.unittest
def test_download_cmems_forecast(tmp_path):
date_min = pd.Timestamp.today()
Expand Down
Loading