Skip to content

Commit 36ff14d

Browse files
committed
chore: enhance testing workflow and API test execution
- Added new steps to the GitHub Actions workflow to run real API tests and end-to-end tests with the actual OpenAI API key. - Removed API key validation checks from test cases, allowing all tests to run regardless of API key status. - Streamlined test cases for better readability and maintainability. These changes improve the testing process and ensure comprehensive test coverage.
1 parent b54568e commit 36ff14d

4 files changed

Lines changed: 20 additions & 58 deletions

File tree

.github/workflows/unittest.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,18 @@ jobs:
472472
# Run the fastest, most essential tests
473473
cd src/praisonai && python tests/test_runner.py --pattern fast
474474
475+
- name: Run Real API Tests
476+
run: |
477+
echo "🔑 Running real API tests with actual OpenAI API key..."
478+
cd src/praisonai && python -m pytest tests/test_agents_playbook.py -v --tb=short --disable-warnings -m real
479+
continue-on-error: true
480+
481+
- name: Run E2E Real Tests
482+
run: |
483+
echo "🧪 Running E2E real tests..."
484+
cd src/praisonai && python -m pytest tests/e2e/ -v --tb=short --disable-warnings -m real
485+
continue-on-error: true
486+
475487
- name: Run Legacy Example Tests
476488
run: |
477489
cd src/praisonai && python -m pytest tests/test.py -v --tb=short --disable-warnings

src/praisonai/tests/e2e/autogen/test_autogen_real.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "../../../src"))
2020

2121
@pytest.mark.real
22-
@pytest.mark.skipif(not os.getenv("OPENAI_API_KEY"), reason="No API key - skipping real tests")
2322
class TestAutoGenReal:
2423
"""Real AutoGen tests with actual API calls"""
2524

src/praisonai/tests/e2e/crewai/test_crewai_real.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "../../../src"))
2020

2121
@pytest.mark.real
22-
@pytest.mark.skipif(not os.getenv("OPENAI_API_KEY"), reason="No API key - skipping real tests")
2322
class TestCrewAIReal:
2423
"""Real CrewAI tests with actual API calls"""
2524

src/praisonai/tests/test_agents_playbook.py

Lines changed: 8 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -10,75 +10,27 @@ class TestPraisonAIFramework(unittest.TestCase):
1010
@pytest.mark.real
1111
def test_main_with_autogen_framework(self):
1212
"""Test AutoGen framework integration with real API calls"""
13-
# Check if we have a real API key
14-
api_key = os.environ.get('OPENAI_API_KEY')
15-
if not api_key or api_key == 'test-key' or api_key.startswith('sk-test-'):
16-
self.skipTest("Skipping real test - no valid OPENAI_API_KEY provided")
17-
1813
praisonai = PraisonAI(agent_file='tests/autogen-agents.yaml')
19-
try:
20-
result = praisonai.run()
21-
self.assertIn('### Output ###', result)
22-
except Exception as e:
23-
if ('Invalid API Key' in str(e) or 'AuthenticationError' in str(e) or
24-
'InstructorRetryException' in str(e) or '401' in str(e)):
25-
self.skipTest(f"Skipping due to API authentication: {e}")
26-
else:
27-
raise
14+
result = praisonai.run()
15+
self.assertIn('### Output ###', result)
2816

2917
@pytest.mark.real
3018
def test_main_with_custom_framework(self):
3119
"""Test CrewAI framework integration with real API calls"""
32-
# Check if we have a real API key
33-
api_key = os.environ.get('OPENAI_API_KEY')
34-
if not api_key or api_key == 'test-key' or api_key.startswith('sk-test-'):
35-
self.skipTest("Skipping real test - no valid OPENAI_API_KEY provided")
36-
3720
praisonai = PraisonAI(agent_file='tests/crewai-agents.yaml')
38-
try:
39-
result = praisonai.run()
40-
self.assertIn('### Task Output ###', result)
41-
except Exception as e:
42-
if ('Invalid API Key' in str(e) or 'AuthenticationError' in str(e) or
43-
'InstructorRetryException' in str(e) or '401' in str(e)):
44-
self.skipTest(f"Skipping due to API authentication: {e}")
45-
else:
46-
raise
21+
result = praisonai.run()
22+
self.assertIn('### Task Output ###', result)
4723

4824
@pytest.mark.real
4925
def test_main_with_internet_search_tool(self):
5026
"""Test internet search tool integration with real API calls"""
51-
# Check if we have a real API key
52-
api_key = os.environ.get('OPENAI_API_KEY')
53-
if not api_key or api_key == 'test-key' or api_key.startswith('sk-test-'):
54-
self.skipTest("Skipping real test - no valid OPENAI_API_KEY provided")
55-
5627
praisonai = PraisonAI(agent_file='tests/search-tool-agents.yaml')
57-
try:
58-
result = praisonai.run()
59-
self.assertIn('### Task Output ###', result)
60-
except Exception as e:
61-
if ('Invalid API Key' in str(e) or 'AuthenticationError' in str(e) or
62-
'InstructorRetryException' in str(e) or '401' in str(e)):
63-
self.skipTest(f"Skipping due to API authentication: {e}")
64-
else:
65-
raise
28+
result = praisonai.run()
29+
self.assertIn('### Task Output ###', result)
6630

6731
@pytest.mark.real
6832
def test_main_with_built_in_tool(self):
6933
"""Test built-in tool integration with real API calls"""
70-
# Check if we have a real API key
71-
api_key = os.environ.get('OPENAI_API_KEY')
72-
if not api_key or api_key == 'test-key' or api_key.startswith('sk-test-'):
73-
self.skipTest("Skipping real test - no valid OPENAI_API_KEY provided")
74-
7534
praisonai = PraisonAI(agent_file='tests/inbuilt-tool-agents.yaml')
76-
try:
77-
result = praisonai.run()
78-
self.assertIn('### Task Output ###', result)
79-
except Exception as e:
80-
if ('Invalid API Key' in str(e) or 'AuthenticationError' in str(e) or
81-
'InstructorRetryException' in str(e) or '401' in str(e)):
82-
self.skipTest(f"Skipping due to API authentication: {e}")
83-
else:
84-
raise
35+
result = praisonai.run()
36+
self.assertIn('### Task Output ###', result)

0 commit comments

Comments
 (0)