Skip to content

Commit

Permalink
Bring cli back (#300)
Browse files Browse the repository at this point in the history
* Add nomenclature cli to pyproject.toml

* Add explicit check for presence of CLI

* Try to force windows to use bash for cli test

* Add separate cli test for windows

* Fix conditional skip

* Mark cli check as expected fail on Windows
  • Loading branch information
phackstock committed Jan 5, 2024
1 parent 72fec3f commit a52e25e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ sphinx = "^7.2.6"
sphinx-click = "^5.1.0"
numpydoc = "^1.6.0"

[tool.poetry.scripts]
nomenclature = 'nomenclature.cli:cli'

[tool.poetry-dynamic-versioning]
bump = true
Expand Down
26 changes: 26 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import subprocess
import sys

from click.testing import CliRunner
from nomenclature import cli
from nomenclature.testing import assert_valid_yaml, assert_valid_structure
Expand All @@ -9,6 +12,29 @@
runner = CliRunner()


@pytest.mark.xfail(
sys.platform.startswith("win"),
reason="Command to invoke the cli does not work on Windows",
)
def test_cli_installed():
command = "poetry run nomenclature"
result = subprocess.run(
command,
capture_output=True,
text=True,
shell=True,
check=True,
)
assert all(
command in result.stdout
for command in (
"check-region-aggregation",
"validate-project",
"validate-yaml",
)
)


def test_cli_valid_yaml_path():
"""Check that CLI throws an error when the `path` is incorrect"""
result_valid = runner.invoke(
Expand Down

0 comments on commit a52e25e

Please sign in to comment.