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

ACCESS-OM3 QA Tests #63

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "model_config_tests"
version = "0.0.7"
version = "0.0.8"
authors = [
{ name = "ACCESS-NRI" },
]
Expand Down
67 changes: 65 additions & 2 deletions src/model_config_tests/qa/test_access_om3_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,75 @@

"""ACCESS-OM3 specific configuration tests"""

import re
from pathlib import Path

import pytest
from payu.models.cesm_cmeps import Runconfig

#########################
# Valid field constants #
#########################

# Error message functions


def error_runconfig_variable_none(section: str, variable: str) -> str:
return f"nuopc.runconfig: section '{section}' variable {variable} does not exist."

Check warning on line 20 in src/model_config_tests/qa/test_access_om3_config.py

View check run for this annotation

Codecov / codecov/patch

src/model_config_tests/qa/test_access_om3_config.py#L20

Added line #L20 was not covered by tests


def error_runseq_variable_none(variable: str) -> str:
return f"nuopc.runseq: {variable} does not exist."

Check warning on line 24 in src/model_config_tests/qa/test_access_om3_config.py

View check run for this annotation

Codecov / codecov/patch

src/model_config_tests/qa/test_access_om3_config.py#L24

Added line #L24 was not covered by tests


################################
# ACCESS-OM3-specific Fixtures #
################################


@pytest.fixture(scope="class")
def nuopc_runconfig(control_path: Path) -> Runconfig:
runconfig_path: Path = control_path / "nuopc.runconfig"

Check warning on line 34 in src/model_config_tests/qa/test_access_om3_config.py

View check run for this annotation

Codecov / codecov/patch

src/model_config_tests/qa/test_access_om3_config.py#L34

Added line #L34 was not covered by tests

return Runconfig(runconfig_path)

Check warning on line 36 in src/model_config_tests/qa/test_access_om3_config.py

View check run for this annotation

Codecov / codecov/patch

src/model_config_tests/qa/test_access_om3_config.py#L36

Added line #L36 was not covered by tests


@pytest.fixture(scope="class")
def nuopc_runseq(control_path: Path) -> list[str]:
runseq_path: Path = control_path / "nuopc.runseq"

Check warning on line 41 in src/model_config_tests/qa/test_access_om3_config.py

View check run for this annotation

Codecov / codecov/patch

src/model_config_tests/qa/test_access_om3_config.py#L41

Added line #L41 was not covered by tests

with open(runseq_path) as f:

Check warning on line 43 in src/model_config_tests/qa/test_access_om3_config.py

View check run for this annotation

Codecov / codecov/patch

src/model_config_tests/qa/test_access_om3_config.py#L43

Added line #L43 was not covered by tests
# FIXME: Find something better
return f.readlines()

Check warning on line 45 in src/model_config_tests/qa/test_access_om3_config.py

View check run for this annotation

Codecov / codecov/patch

src/model_config_tests/qa/test_access_om3_config.py#L45

Added line #L45 was not covered by tests


#########
# Tests #
#########


@pytest.mark.access_om3
class TestAccessOM3:
"""ACCESS-OM3 Specific configuration and metadata tests"""

def test_pass(self):
pass
def test_runconfig_ocn_cpl_dt_equals_runseq_coupling_timestep(
self, nuopc_runconfig: Runconfig, nuopc_runseq: list[str]
):
# Setup runconfig variable
rcfg_section = "CLOCK_attributes"
rcfg_variable = "ocn_cpl_dt"
rcfg_ocn_cpl_dt = nuopc_runconfig.get(rcfg_section, rcfg_variable)

Check warning on line 63 in src/model_config_tests/qa/test_access_om3_config.py

View check run for this annotation

Codecov / codecov/patch

src/model_config_tests/qa/test_access_om3_config.py#L61-L63

Added lines #L61 - L63 were not covered by tests

assert rcfg_ocn_cpl_dt, error_runconfig_variable_none(

Check warning on line 65 in src/model_config_tests/qa/test_access_om3_config.py

View check run for this annotation

Codecov / codecov/patch

src/model_config_tests/qa/test_access_om3_config.py#L65

Added line #L65 was not covered by tests
rcfg_section, rcfg_variable
)

# Setup runseq variable
rseq_cpl_ts_match: str = [

Check warning on line 70 in src/model_config_tests/qa/test_access_om3_config.py

View check run for this annotation

Codecov / codecov/patch

src/model_config_tests/qa/test_access_om3_config.py#L70

Added line #L70 was not covered by tests
line for line in nuopc_runseq if re.match(r"@(\S*)", line)
][0]
rseq_cpl_ts = rseq_cpl_ts_match.group(1)

Check warning on line 73 in src/model_config_tests/qa/test_access_om3_config.py

View check run for this annotation

Codecov / codecov/patch

src/model_config_tests/qa/test_access_om3_config.py#L73

Added line #L73 was not covered by tests

assert rseq_cpl_ts, error_runseq_variable_none("coupling timestep")

Check warning on line 75 in src/model_config_tests/qa/test_access_om3_config.py

View check run for this annotation

Codecov / codecov/patch

src/model_config_tests/qa/test_access_om3_config.py#L75

Added line #L75 was not covered by tests

assert rcfg_ocn_cpl_dt == rseq_cpl_ts

Check warning on line 77 in src/model_config_tests/qa/test_access_om3_config.py

View check run for this annotation

Codecov / codecov/patch

src/model_config_tests/qa/test_access_om3_config.py#L77

Added line #L77 was not covered by tests
Loading