Summary
The n8n integration in praisonai-tools is fully implemented and functional. This issue tracks minor test mocking issues that cause 2 test failures.
Implementation Status: ✅ Complete
What's Working
- ✅
N8nWorkflowTool class — executes n8n workflows via Public API
- ✅
n8n_workflow() function — decorated tool for agents
- ✅
n8n_list_workflows() function — lists available workflows
- ✅ Environment variable support (
N8N_URL, N8N_API_KEY)
- ✅ Lazy httpx import — no import-time overhead
- ✅ Timeout and error handling
- ✅ Execution polling with
wait_for_completion
Test Results
11 passed, 2 failed, 2 skipped (integration tests)
Test Failures
1. test_n8n_workflow_missing_httpx
File: tests/test_n8n_integration.py:72
The mock patch path is incorrect:
# Current (fails):
with patch('praisonai_tools.n8n.n8n_workflow.httpx', None):
# Fix — use sys.modules approach:
with patch.dict('sys.modules', {'httpx': None}):
# Force reimport to trigger ImportError
2. test_n8n_workflow_http_error / test_n8n_workflow_timeout_error
File: tests/test_n8n_integration.py:111, 131
The mock fixture mock_httpx doesn't properly mock the lazy import inside the run() method. The httpx module is imported inside the method, so the mock needs to intercept the actual import.
Fix:
@pytest.fixture
def mock_httpx(self):
"""Mock httpx module for testing."""
mock_module = MagicMock()
mock_module.TimeoutException = type('TimeoutException', (Exception,), {})
mock_module.HTTPStatusError = type('HTTPStatusError', (Exception,), {
'__init__': lambda self, msg, request, response: setattr(self, 'response', response)
})
with patch.dict('sys.modules', {'httpx': mock_module}):
yield mock_module
Files Involved
| File |
Lines |
Purpose |
praisonai_tools/n8n/__init__.py |
20 |
Exports |
praisonai_tools/n8n/n8n_workflow.py |
252 |
Tool implementation |
tests/test_n8n_integration.py |
314 |
Unit tests |
docs/n8n_integration.md |
— |
Documentation |
examples/n8n_integration_example.py |
— |
Example usage |
Acceptance Criteria
Labels
bug, tests, good first issue
Summary
The n8n integration in praisonai-tools is fully implemented and functional. This issue tracks minor test mocking issues that cause 2 test failures.
Implementation Status: ✅ Complete
What's Working
N8nWorkflowToolclass — executes n8n workflows via Public APIn8n_workflow()function — decorated tool for agentsn8n_list_workflows()function — lists available workflowsN8N_URL,N8N_API_KEY)wait_for_completionTest Results
Test Failures
1.
test_n8n_workflow_missing_httpxFile:
tests/test_n8n_integration.py:72The mock patch path is incorrect:
2.
test_n8n_workflow_http_error/test_n8n_workflow_timeout_errorFile:
tests/test_n8n_integration.py:111, 131The mock fixture
mock_httpxdoesn't properly mock the lazy import inside therun()method. The httpx module is imported inside the method, so the mock needs to intercept the actual import.Fix:
Files Involved
praisonai_tools/n8n/__init__.pypraisonai_tools/n8n/n8n_workflow.pytests/test_n8n_integration.pydocs/n8n_integration.mdexamples/n8n_integration_example.pyAcceptance Criteria
Labels
bug,tests,good first issue