-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
31 bug fix workspace cli command (#40)
* fix(cli/workspace.py): changing filename for active workspace * feat(workflow/http/context.py): adding validator function for workspace field * fix(workspace): fixed workspace cli commands and suppressed UserWarning from pydantic_settings --------- Co-authored-by: Shiny Brar (he/il) <[email protected]>
- Loading branch information
Showing
10 changed files
with
114 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,14 @@ | ||
"""pytest configuration file.""" | ||
|
||
import pytest | ||
from click.testing import CliRunner | ||
|
||
from workflow.cli.main import cli as workflow | ||
|
||
|
||
def pytest_configure(config): | ||
"""Initailize pytest configuration. | ||
Allows plugins and conftest files to perform initial configuration. | ||
This hook is called for every plugin and initial conftest | ||
file after command line options have been parsed. | ||
""" | ||
@pytest.fixture(autouse=True, scope="function") | ||
def set_testing_workspace(): | ||
"""Initailize testing workspace.""" | ||
runner = CliRunner() | ||
runner.invoke(workflow, ["workspace", "set", "development"]) | ||
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
"""Test the workspace CLI commands.""" | ||
|
||
import os | ||
|
||
from click.testing import CliRunner | ||
|
||
from workflow import CONFIG_PATH, DEFAULT_WORKSPACE_PATH | ||
from workflow.cli.workspace import ls, set | ||
|
||
|
||
class TestWorkspaceCLI: | ||
def test_workspace_ls(self): | ||
runner = CliRunner() | ||
result = runner.invoke(ls) | ||
assert result.exit_code == 0 | ||
assert "From Workflow Python Module" in result.output | ||
assert "development" in result.output | ||
|
||
def test_workspace_set(self): | ||
runner = CliRunner() | ||
result = runner.invoke(set, ["development"]) | ||
assert result.exit_code == 0 | ||
assert "Locating workspace development" in result.output | ||
assert "Workspace development set to active" in result.output | ||
# ? Check the default folder only contains the active workspace file | ||
entries = os.listdir(CONFIG_PATH) | ||
files = [ | ||
CONFIG_PATH / entry | ||
for entry in entries | ||
if os.path.isfile(os.path.join(CONFIG_PATH, entry)) | ||
] | ||
files = [f.as_posix() for f in files] | ||
assert files == [DEFAULT_WORKSPACE_PATH.as_posix()] | ||
# ? Re set workspace for other tests | ||
result = runner.invoke(set, ["development"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,17 @@ | ||
"""Top-level imports for Tasks API.""" | ||
|
||
from pathlib import Path | ||
from warnings import filterwarnings | ||
|
||
# Ignore UserWarnings from pydantic_settings module | ||
# These usually come when no docker secrets are found | ||
filterwarnings("ignore", category=UserWarning, module="pydantic_settings") | ||
|
||
# Root path to the Workflow Module | ||
MODULE_PATH: Path = Path(__file__).absolute().parent.parent | ||
# Path to local configurations | ||
CONFIG_PATH: Path = Path.home() / ".workflow" | ||
CONFIG_PATH: Path = Path.home() / ".config" / "workflow" | ||
# Active Workspace Path | ||
DEFAULT_WORKSPACE_PATH: Path = CONFIG_PATH / "workspaces" / "active.yml" | ||
DEFAULT_WORKSPACE_PATH: Path = CONFIG_PATH / "workspace.yml" | ||
# Workflow Client Version | ||
__version__ = "0.3.0" # {x-release-please-version} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters