-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathtest.py
More file actions
101 lines (87 loc) · 3.72 KB
/
test.py
File metadata and controls
101 lines (87 loc) · 3.72 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
import unittest
import subprocess
from praisonai.cli import PraisonAI
from .advanced_example import advanced
from .basic_example import main
from .auto_example import auto
# from xmlrunner import XMLTestRunner
# Patch for collections.abc MutableMapping issue
import collections.abc
collections.MutableMapping = collections.abc.MutableMapping
class TestPraisonAIFramework(unittest.TestCase):
def test_main_with_agents_advanced(self):
praisonai = PraisonAI(agent_file='tests/agents-advanced.yaml')
result = praisonai.run()
self.assertIn('Task Output', result)
def test_main_with_autogen_framework(self):
praisonai = PraisonAI(agent_file='tests/autogen-agents.yaml')
result = praisonai.run()
self.assertTrue('Task Output' in result or '### Output ###' in result)
def test_main_with_custom_framework(self):
praisonai = PraisonAI(agent_file='tests/crewai-agents.yaml')
result = praisonai.run()
self.assertIn('Task Output', result)
def test_main_with_internet_search_tool(self):
praisonai = PraisonAI(agent_file='tests/search-tool-agents.yaml')
result = praisonai.run()
self.assertIn('Task Output', result)
def test_main_with_built_in_tool(self):
praisonai = PraisonAI(agent_file='tests/inbuilt-tool-agents.yaml')
result = praisonai.run()
self.assertIn('Task Output', result)
class TestPraisonAICommandLine(unittest.TestCase):
def run_command(self, command):
result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True, text=True)
return result.stdout
def test_praisonai_command(self):
command = "praisonai --framework autogen --auto create movie script about cat in mars"
result = self.run_command(command)
self.assertIn('TERMINATE', result)
def test_praisonai_init_command(self):
command = "praisonai --framework autogen --init create movie script about cat in mars"
result = self.run_command(command)
self.assertIn('created successfully', result)
class TestExamples(unittest.TestCase):
def test_basic_example(self):
# Test the basic example function
result = main()
self.assertIsNotNone(result)
# Check if result contains expected success indicators or output
self.assertTrue(
isinstance(result, str) and (
"completed successfully" in result or
"Task Output" in result or
len(result.strip()) > 0
),
f"Expected meaningful result, got: {result}"
)
def test_advanced_example(self):
# Test the advanced example function
result = advanced()
self.assertIsNotNone(result)
# Check if result contains expected success indicators or output
self.assertTrue(
isinstance(result, str) and (
"completed successfully" in result or
"Task Output" in result or
len(result.strip()) > 0
),
f"Expected meaningful result, got: {result}"
)
def test_auto_example(self):
# Test the auto example function
result = auto()
self.assertIsNotNone(result)
# Check if result contains expected success indicators or output
self.assertTrue(
isinstance(result, str) and (
"completed successfully" in result or
"Task Output" in result or
len(result.strip()) > 0
),
f"Expected meaningful result, got: {result}"
)
if __name__ == '__main__':
# runner = XMLTestRunner(output='test-reports')
unittest.main()
# unittest.main(testRunner=runner, exit=False)