-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconftest.py
More file actions
144 lines (120 loc) · 3.7 KB
/
conftest.py
File metadata and controls
144 lines (120 loc) · 3.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/usr/bin/env python3
"""
Pytest fixtures for LLMSender tests.
"""
import pytest
from typing import Dict, Any
@pytest.fixture
def mock_config() -> Dict[str, Any]:
"""Provide a mock configuration for testing."""
return {
'tasks': [],
'timezone': 'UTC',
'log_level': 'DEBUG'
}
@pytest.fixture
def mock_task_config() -> Dict[str, Any]:
"""Provide a mock task configuration for testing."""
return {
'name': 'Test Task',
'content': {
'plugin': 'test_content'
},
'llm': {
'plugin': 'test_llm'
},
'notifiers': [
{'plugin': 'test_notifier'}
]
}
@pytest.fixture
def mock_pack_task_config() -> Dict[str, Any]:
"""Provide a mock pack-based task configuration for testing."""
return {
'name': 'Test Pack Task',
'pack': 'core/test_pack',
'content': {
'type': 'default'
},
'llm': {
'plugin': 'test_llm'
},
'actions': [
{'type': 'core/core_actions.filter', 'min_length': 10}
],
'notifiers': [
{'type': 'test_notifier'}
]
}
@pytest.fixture
def sample_llm_output() -> str:
"""Provide sample LLM output for testing."""
return "This is a test summary of the content. It contains multiple sentences. The content is interesting."
@pytest.fixture
def sample_context() -> Dict[str, Any]:
"""Provide sample context for action testing."""
return {
'task_name': 'test_task',
'content': 'Original test content',
'prompt': 'Test prompt',
'trigger_data': {}
}
@pytest.fixture(autouse=True)
def reset_singletons():
"""Reset singleton instances before each test."""
yield
# Reset after test
try:
from core.pack_loader import reset_pack_loader
reset_pack_loader()
except ImportError:
# Optional in some test configurations; skip reset if not available.
pass
try:
from core.action_system import reset_action_pipeline
reset_action_pipeline()
except ImportError:
# Optional in some test configurations; skip reset if not available.
pass
try:
from core.trigger_system import reset_trigger_manager
reset_trigger_manager()
except ImportError:
# Optional in some test configurations; skip reset if not available.
pass
try:
from core.task_executor import reset_task_executor
reset_task_executor()
except ImportError:
# Optional in some test configurations; skip reset if not available.
pass
# Helper functions for creating mock objects
def create_mock_content_provider(fetch_return: str = "Test content", prompt_return: str = "Test prompt"):
"""Create a mock content provider."""
from test.mocks.mock_plugins import MockContentProvider
return MockContentProvider({
'_fetch_return': fetch_return,
'_prompt_return': prompt_return
})
def create_mock_llm_sender(summarize_return: str = "Test summary"):
"""Create a mock LLM sender."""
from test.mocks.mock_plugins import MockLLMSender
return MockLLMSender({
'_summarize_return': summarize_return
})
def create_mock_notifier(send_return: bool = True):
"""Create a mock notifier."""
from test.mocks.mock_plugins import MockNotifier
return MockNotifier({
'_send_return': send_return
})
def create_mock_action(
output: str = "Processed output",
should_continue: bool = True
):
"""Create a mock action."""
from test.mocks.mock_plugins import MockAction
return MockAction({
'_output': output,
'_should_continue': should_continue
})