Skip to content

Commit

Permalink
simplify test_deny_nodes() logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Lincoln Stein committed Apr 25, 2024
1 parent 3495b32 commit 2ef6781
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,6 @@
i like turtles
"""

deny_nodes_config = """
schema_version: 4.0.1
allow_nodes:
- integer
- string
- float
deny_nodes:
- float
"""


@pytest.fixture
def patch_rootdir(tmp_path: Path, monkeypatch: Any) -> None:
Expand Down Expand Up @@ -296,14 +285,10 @@ def test_get_config_writing(patch_rootdir: None, monkeypatch: pytest.MonkeyPatch
InvokeAIArgs.did_parse = False


def test_deny_nodes(tmp_path: Path, monkeypatch: pytest.MonkeyPatch):
# Allow integer, string and float, but explicitly deny float
temp_config_file = tmp_path / "invokeai.yaml"
temp_config_file.write_text(deny_nodes_config)
monkeypatch.setenv("INVOKEAI_ROOT", str(tmp_path))

get_config.cache_clear()
InvokeAIArgs.did_parse = True
def test_deny_nodes():
config = get_config()
config.allow_nodes = ["integer", "string", "float"]
config.deny_nodes = ["float"]

# confirm invocations union will not have denied nodes
all_invocations = BaseInvocation.get_invocations()
Expand All @@ -315,3 +300,6 @@ def test_deny_nodes(tmp_path: Path, monkeypatch: pytest.MonkeyPatch):
assert has_integer
assert has_string
assert not has_float

# may not be necessary
get_config.cache_clear()

0 comments on commit 2ef6781

Please sign in to comment.