35 lines
1.5 KiB
Python
35 lines
1.5 KiB
Python
import unittest
|
|
from pathlib import Path
|
|
|
|
from api_key_utils import resolve_api_key_path
|
|
|
|
|
|
class ApiKeyUtilsTests(unittest.TestCase):
|
|
def test_resolves_api_key_beside_requesting_module(self):
|
|
module_file = Path("custom_nodes") / "PromptNodes" / "qwen_nodes.py"
|
|
|
|
result = Path(resolve_api_key_path(str(module_file)))
|
|
|
|
self.assertEqual(result, module_file.resolve().parent / "api_key.txt")
|
|
|
|
def test_does_not_depend_on_repository_directory_name(self):
|
|
original = Path("custom_nodes") / "ComfyUI-MultiModal-Prompt-Nodes" / "wan_nodes.py"
|
|
renamed = Path("custom_nodes") / "My-Renamed-Prompt-Nodes" / "wan_nodes.py"
|
|
|
|
original_result = Path(resolve_api_key_path(str(original)))
|
|
renamed_result = Path(resolve_api_key_path(str(renamed)))
|
|
|
|
self.assertEqual(original_result.parent.name, "ComfyUI-MultiModal-Prompt-Nodes")
|
|
self.assertEqual(renamed_result.parent.name, "My-Renamed-Prompt-Nodes")
|
|
|
|
def test_keeps_separate_custom_node_roots_independent(self):
|
|
first = Path("primary") / "custom_nodes" / "PromptNodes" / "qwen_nodes.py"
|
|
second = Path("additional") / "custom_nodes" / "PromptNodes" / "qwen_nodes.py"
|
|
|
|
first_result = Path(resolve_api_key_path(str(first)))
|
|
second_result = Path(resolve_api_key_path(str(second)))
|
|
|
|
self.assertNotEqual(first_result, second_result)
|
|
self.assertEqual(first_result.name, "api_key.txt")
|
|
self.assertEqual(second_result.name, "api_key.txt")
|