pixie-prompts 0.0.0__py3-none-any.whl → 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pixie/prompts/__init__.py +19 -0
- pixie/prompts/file_watcher.py +320 -0
- pixie/prompts/graphql.py +17 -10
- pixie/prompts/prompt.py +4 -4
- pixie/prompts/server.py +16 -48
- pixie/prompts/storage.py +206 -35
- {pixie_prompts-0.0.0.dist-info → pixie_prompts-0.1.0.dist-info}/METADATA +2 -1
- pixie_prompts-0.1.0.dist-info/RECORD +12 -0
- pixie_prompts-0.1.0.dist-info/entry_points.txt +3 -0
- pixie/tests/__init__.py +0 -0
- pixie/tests/test_prompt.py +0 -1321
- pixie/tests/test_prompt_management.py +0 -117
- pixie/tests/test_prompt_storage.py +0 -1453
- pixie_prompts-0.0.0.dist-info/RECORD +0 -15
- pixie_prompts-0.0.0.dist-info/entry_points.txt +0 -3
- {pixie_prompts-0.0.0.dist-info → pixie_prompts-0.1.0.dist-info}/WHEEL +0 -0
- {pixie_prompts-0.0.0.dist-info → pixie_prompts-0.1.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import pytest
|
|
2
|
-
from types import NoneType
|
|
3
|
-
|
|
4
|
-
from pixie.prompts.prompt_management import (
|
|
5
|
-
create_prompt,
|
|
6
|
-
list_prompts,
|
|
7
|
-
get_prompt,
|
|
8
|
-
_registry,
|
|
9
|
-
)
|
|
10
|
-
from pixie.prompts.prompt import PromptVariables
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
class DummyVar1(PromptVariables):
|
|
14
|
-
pass
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class DummyVar2(PromptVariables):
|
|
18
|
-
pass
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
class TestPromptManagement:
|
|
22
|
-
def setup_method(self):
|
|
23
|
-
"""Clear the registry before each test."""
|
|
24
|
-
_registry.clear()
|
|
25
|
-
|
|
26
|
-
def test_create_prompt_without_description(self):
|
|
27
|
-
"""Test creating a prompt without description."""
|
|
28
|
-
prompt = create_prompt("test_prompt")
|
|
29
|
-
|
|
30
|
-
assert prompt.id == "test_prompt"
|
|
31
|
-
assert prompt.variables_definition == NoneType
|
|
32
|
-
|
|
33
|
-
# Check registry
|
|
34
|
-
registered = get_prompt("test_prompt")
|
|
35
|
-
assert registered is not None
|
|
36
|
-
assert registered.description is None
|
|
37
|
-
assert registered.module == __name__
|
|
38
|
-
assert registered.prompt is prompt
|
|
39
|
-
|
|
40
|
-
def test_create_prompt_with_description(self):
|
|
41
|
-
"""Test creating a prompt with description."""
|
|
42
|
-
description = "A test prompt description"
|
|
43
|
-
prompt = create_prompt("test_prompt_desc", description=description)
|
|
44
|
-
|
|
45
|
-
assert prompt.id == "test_prompt_desc"
|
|
46
|
-
|
|
47
|
-
# Check registry
|
|
48
|
-
registered = get_prompt("test_prompt_desc")
|
|
49
|
-
assert registered is not None
|
|
50
|
-
assert registered.description == description
|
|
51
|
-
assert registered.module == __name__
|
|
52
|
-
assert registered.prompt is prompt
|
|
53
|
-
|
|
54
|
-
def test_create_prompt_same_id_same_vars(self):
|
|
55
|
-
"""Test creating a prompt with same id and same variables_definition returns existing."""
|
|
56
|
-
prompt1 = create_prompt("duplicate_prompt")
|
|
57
|
-
prompt2 = create_prompt("duplicate_prompt")
|
|
58
|
-
|
|
59
|
-
assert prompt1 is prompt2
|
|
60
|
-
|
|
61
|
-
# Check registry has only one entry
|
|
62
|
-
registered = get_prompt("duplicate_prompt")
|
|
63
|
-
assert registered is not None
|
|
64
|
-
assert registered.prompt is prompt1
|
|
65
|
-
|
|
66
|
-
def test_create_prompt_same_id_different_vars_raises_error(self):
|
|
67
|
-
"""Test creating a prompt with same id but different variables_definition raises ValueError."""
|
|
68
|
-
# First create with DummyVar1
|
|
69
|
-
create_prompt("conflict_prompt", variables_definition=DummyVar1)
|
|
70
|
-
|
|
71
|
-
# Try to create with DummyVar2
|
|
72
|
-
with pytest.raises(
|
|
73
|
-
ValueError,
|
|
74
|
-
match="Prompt with id 'conflict_prompt' already exists with a different variables definition",
|
|
75
|
-
):
|
|
76
|
-
create_prompt("conflict_prompt", variables_definition=DummyVar2)
|
|
77
|
-
|
|
78
|
-
def test_list_prompts(self):
|
|
79
|
-
"""Test listing all prompts."""
|
|
80
|
-
# Initially empty
|
|
81
|
-
assert list_prompts() == []
|
|
82
|
-
|
|
83
|
-
# Add some prompts
|
|
84
|
-
create_prompt("prompt1", description="First prompt")
|
|
85
|
-
create_prompt("prompt2", description="Second prompt")
|
|
86
|
-
|
|
87
|
-
prompts = list_prompts()
|
|
88
|
-
assert len(prompts) == 2
|
|
89
|
-
|
|
90
|
-
# Check contents
|
|
91
|
-
ids = {p.prompt.id for p in prompts}
|
|
92
|
-
assert ids == {"prompt1", "prompt2"}
|
|
93
|
-
|
|
94
|
-
descriptions = {p.description for p in prompts}
|
|
95
|
-
assert descriptions == {"First prompt", "Second prompt"}
|
|
96
|
-
|
|
97
|
-
def test_get_prompt_existing(self):
|
|
98
|
-
"""Test getting an existing prompt."""
|
|
99
|
-
prompt = create_prompt("existing_prompt", description="Exists")
|
|
100
|
-
registered = get_prompt("existing_prompt")
|
|
101
|
-
|
|
102
|
-
assert registered is not None
|
|
103
|
-
assert registered.prompt is prompt
|
|
104
|
-
assert registered.description == "Exists"
|
|
105
|
-
|
|
106
|
-
def test_get_prompt_nonexistent(self):
|
|
107
|
-
"""Test getting a nonexistent prompt returns None."""
|
|
108
|
-
assert get_prompt("nonexistent") is None
|
|
109
|
-
|
|
110
|
-
def test_module_registration(self):
|
|
111
|
-
"""Test that module is correctly registered as the calling module."""
|
|
112
|
-
create_prompt("module_test")
|
|
113
|
-
registered = get_prompt("module_test")
|
|
114
|
-
|
|
115
|
-
# In this test context, it should be the test module
|
|
116
|
-
assert registered is not None
|
|
117
|
-
assert registered.module == __name__
|