diff --git a/tests/test_cli.py b/tests/test_cli.py index 52ecd4b73..cb81a2341 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -1,7 +1,4 @@ -import os import subprocess -import typing -from pathlib import Path import pytest @@ -12,17 +9,6 @@ DOMAIN_NAME = "clitest.dev" -def run_cli_cmd(command: str, working_dir: typing.Union[str, Path]): - """Run the provided CLI command using subprocess.""" - try: - os.chdir(working_dir) - subprocess.call(command.split()) - except subprocess.CalledProcessError: - return False - - return True - - @pytest.mark.parametrize( "namespace, auth_provider, ci_provider, ssl_cert_email", ( @@ -32,28 +18,35 @@ def run_cli_cmd(command: str, working_dir: typing.Union[str, Path]): ) def test_nebari_init(tmp_path, namespace, auth_provider, ci_provider, ssl_cert_email): """Test `nebari init` CLI command.""" - command = f"nebari init local --project {PROJECT_NAME} --domain {DOMAIN_NAME} --disable-prompt" + command = [ + "nebari", + "init", + "local", + f"--project={PROJECT_NAME}", + f"--domain={DOMAIN_NAME}", + "--disable-prompt", + ] default_values = InitInputs() if namespace: - command += f" --namespace {namespace}" + command.append(f"--namespace={namespace}") else: namespace = default_values.namespace if auth_provider: - command += f" --auth-provider {auth_provider}" + command.append(f"--auth-provider={auth_provider}") else: auth_provider = default_values.auth_provider if ci_provider: - command += f" --ci-provider {ci_provider}" + command.append(f"--ci-provider={ci_provider}") else: ci_provider = default_values.ci_provider if ssl_cert_email: - command += f" --ssl-cert-email {ssl_cert_email}" + command.append(f"--ssl-cert-email={ssl_cert_email}") else: ssl_cert_email = default_values.ssl_cert_email - assert run_cli_cmd(command, tmp_path) + subprocess.run(command, cwd=tmp_path, check=True) config = load_yaml(tmp_path / "nebari-config.yaml") @@ -67,7 +60,6 @@ def test_nebari_init(tmp_path, namespace, auth_provider, ci_provider, ssl_cert_e assert ci_cd.get("type", {}) == ci_provider else: assert ci_cd == ci_provider - ci_cd = config.get("ci_cd", None) acme_email = config.get("certificate", None) if acme_email: assert acme_email.get("acme_email") == ssl_cert_email