From d5a8475be62488182a3e7e8d64fe19ab5ef86db3 Mon Sep 17 00:00:00 2001 From: burnettk Date: Wed, 8 Feb 2023 14:02:17 -0500 Subject: [PATCH] pyl --- .../src/spiffworkflow_backend/config/__init__.py | 5 ++++- .../spiffworkflow_backend/services/service_task_service.py | 6 +++--- .../unit/test_service_task_delegate.py | 6 ++++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/config/__init__.py b/spiffworkflow-backend/src/spiffworkflow_backend/config/__init__.py index 63ce21eec..13a327ef1 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/config/__init__.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/config/__init__.py @@ -91,7 +91,10 @@ def setup_config(app: Flask) -> None: # This allows config/testing.py or instance/config.py to override the default config if "ENV_IDENTIFIER" in app.config and app.config["ENV_IDENTIFIER"] == "testing": app.config.from_pyfile("config/testing.py", silent=True) - elif "ENV_IDENTIFIER" in app.config and app.config["ENV_IDENTIFIER"] == "unit_testing": + elif ( + "ENV_IDENTIFIER" in app.config + and app.config["ENV_IDENTIFIER"] == "unit_testing" + ): app.config.from_pyfile("config/unit_testing.py", silent=True) else: app.config.from_pyfile(f"{app.instance_path}/config.py", silent=True) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/service_task_service.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/service_task_service.py index da3a65bba..982436112 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/service_task_service.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/service_task_service.py @@ -45,7 +45,7 @@ class ServiceTaskDelegate: @staticmethod def get_message_for_status(code: int) -> str: - """Given a code like 404, return a string like 'The requested resource was not found.'""" + """Given a code like 404, return a string like: The requested resource was not found.""" msg = f"HTTP Status Code {code}." if code == 301: msg = ( @@ -110,10 +110,10 @@ class ServiceTaskDelegate: parsed_response = {} if proxied_response.status_code >= 300: - error = f"Received an unexpected response from the service : " - error += ServiceTaskDelegate.get_message_for_status( + message = ServiceTaskDelegate.get_message_for_status( proxied_response.status_code ) + error = f"Received an unexpected response from the service : {message}" if "error" in parsed_response: error += parsed_response["error"] if json_parse_error: diff --git a/spiffworkflow-backend/tests/spiffworkflow_backend/unit/test_service_task_delegate.py b/spiffworkflow-backend/tests/spiffworkflow_backend/unit/test_service_task_delegate.py index 188722fa9..8348d65cc 100644 --- a/spiffworkflow-backend/tests/spiffworkflow_backend/unit/test_service_task_delegate.py +++ b/spiffworkflow-backend/tests/spiffworkflow_backend/unit/test_service_task_delegate.py @@ -1,8 +1,10 @@ """Test_various_bpmn_constructs.""" +from unittest.mock import patch + 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,7 +39,7 @@ class TestServiceTaskDelegate(BaseTest): def test_invalid_call_returns_good_error_message( self, app: Flask, with_db_and_bpmn_file_cleanup: None ) -> None: - with patch('requests.post') as mock_post: + 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 = ""