-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add test on install command * Test on impl * nit * nit
- Loading branch information
Showing
4 changed files
with
75 additions
and
22 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
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,51 @@ | ||
import os | ||
import pytest | ||
from unittest.mock import patch | ||
from typer.testing import CliRunner | ||
|
||
from comfy_cli.cmdline import app, g_exclusivity, g_gpu_exclusivity | ||
|
||
|
||
@pytest.fixture(scope="function") | ||
def runner(): | ||
g_exclusivity.reset_for_testing() | ||
g_gpu_exclusivity.reset_for_testing() | ||
return CliRunner() | ||
|
||
|
||
@pytest.fixture(scope="function") | ||
def mock_execute(): | ||
with patch("comfy_cli.command.install.execute") as mock: | ||
yield mock | ||
|
||
|
||
@pytest.fixture(scope="function") | ||
def mock_prompt_select_enum(): | ||
def mocked_prompt_select_enum( | ||
question: str, choices: list, force_prompting: bool = False | ||
): | ||
return choices[0] | ||
|
||
with patch( | ||
"comfy_cli.ui.prompt_select_enum", | ||
new=mocked_prompt_select_enum, | ||
) as mock: | ||
yield mock | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"cmd", | ||
[ | ||
["--here", "install"], | ||
["--workspace", "./ComfyUI", "install"], | ||
], | ||
) | ||
def test_install_here(cmd, runner, mock_execute, mock_prompt_select_enum): | ||
result = runner.invoke(app, cmd) | ||
assert result.exit_code == 0, result.stdout | ||
|
||
args, kwargs = mock_execute.call_args | ||
url, manager_url, comfy_path, *_ = args | ||
assert url == "https://github.com/comfyanonymous/ComfyUI" | ||
assert manager_url == "https://github.com/ltdrdata/ComfyUI-Manager" | ||
assert comfy_path == os.path.join(os.getcwd(), "ComfyUI") |
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 @@ | ||
pytest |