Skip to content

Commit

Permalink
Merge pull request #360 from rayference/fix_ci
Browse files Browse the repository at this point in the history
Rename PDM script that automates local coverage report generation
  • Loading branch information
leroyvn authored Dec 15, 2023
2 parents dd5ca86 + bb2e5a0 commit fd03f1a
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
run: |
python -m coverage combine
python -m coverage html --skip-covered --skip-empty
python -m coverage report --fail-under=100
python -m coverage report --fail-under=95
- name: Upload HTML report if check failed
uses: actions/upload-artifact@v2
Expand Down
6 changes: 6 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Fixed

* Added missing tests to bring coverage metric to 100%.

## [2.6.0] - 2023-12-14

### Changed
Expand Down
2 changes: 1 addition & 1 deletion maintainers.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* run the test with `pytest tests`
* to verify the test coverage, run:
```shell
pdm run coverage
pdm run coverage-report
```
and inspect the coverage report.

Expand Down
12 changes: 6 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,16 @@ test = [
]

[tool.pdm.scripts]
coverage = {composite = [
coverage-combine = {cmd = "python -m coverage combine"}
coverage-html = {cmd = "python -m coverage html --skip-covered --skip-empty"}
coverage-pytest = {cmd = "coverage run -m pytest tests"}
coverage-report = {composite = [
"coverage-pytest",
"coverage-combine",
"coverage-report",
"coverage-show",
"coverage-html"
]}
coverage-combine = {cmd = "python -m coverage combine"}
coverage-html = {cmd = "python -m coverage html --skip-covered --skip-empty"}
coverage-pytest = {cmd = "coverage run -m pytest tests"}
coverage-report = {cmd = "python -m coverage report --fail-under=100"}
coverage-show = {cmd = "python -m coverage report --fail-under=100"}

[tool.pdm.version]
path = "src/joseki/__version__.py"
Expand Down
32 changes: 32 additions & 0 deletions tests/test_accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,38 @@ def test_mass_density_at_sea_level(identifier: str, expected: pint.Quantity):
assert_approx_equal(water_vapor_amount.m, expected.m, significant=6)


@pytest.mark.parametrize(
"identifier, expected",
[
("afgl_1986-us_standard", 0.0004621406347),
("mipas_2007-midlatitude_day", 0.000456396845),
],
)
def test_mass_fraction(identifier, expected):
"""Mean CO2 mass fraction matches expected value.
This basic test will detect an obvious regression, but not subtle changes.
"""
ds = joseki.make(identifier)
value = ds.joseki.mass_fraction.sel(m="CO2").mean(dim="z")
assert_approx_equal(value, expected)


@pytest.mark.parametrize(
"identifier, expected",
[
("afgl_1986-us_standard", 0.00030396),
("mipas_2007-midlatitude_day", 0.0003002627),
],
)
def test_mole_fraction(identifier, expected):
"""Mean CO2 mole mixing fraction matches expected value.
This basic test will detect an obvious regression, but not subtle changes.
"""
ds = joseki.make(identifier)
value = ds.joseki.mole_fraction.sel(m="CO2").mean(dim="z")
assert_approx_equal(value, expected)


@pytest.mark.parametrize(
"identifier, expected",
[
Expand Down

0 comments on commit fd03f1a

Please sign in to comment.