Use a mock when making external calls in tests.
This commit is contained in:
parent
b1d4eee781
commit
b5cd11ef37
|
@ -1,8 +1,8 @@
|
|||
"""Test_various_bpmn_constructs."""
|
||||
import pytest
|
||||
from flask.app import Flask
|
||||
from unittest.mock import Mock, patch
|
||||
from tests.spiffworkflow_backend.helpers.base_test import BaseTest
|
||||
|
||||
from spiffworkflow_backend.services.secret_service import SecretService
|
||||
from spiffworkflow_backend.services.service_task_service import ConnectorProxyError
|
||||
from spiffworkflow_backend.services.service_task_service import ServiceTaskDelegate
|
||||
|
@ -37,8 +37,12 @@ class TestServiceTaskDelegate(BaseTest):
|
|||
def test_invalid_call_returns_good_error_message(
|
||||
self, app: Flask, with_db_and_bpmn_file_cleanup: None
|
||||
) -> None:
|
||||
with pytest.raises(ConnectorProxyError) as ae:
|
||||
ServiceTaskDelegate.call_connector("my_invalid_operation", {}, {})
|
||||
with patch('requests.post') as mock_post:
|
||||
mock_post.return_value.status_code = 404
|
||||
mock_post.return_value.ok = True
|
||||
mock_post.return_value.json.return_value = ""
|
||||
with pytest.raises(ConnectorProxyError) as ae:
|
||||
ServiceTaskDelegate.call_connector("my_invalid_operation", {}, {})
|
||||
assert "404" in str(ae)
|
||||
assert "The service did not find the requested resource." in str(ae)
|
||||
assert (
|
||||
|
|
Loading…
Reference in New Issue