From 518a6e16062347656dbeb873dd4570adbf0fc7e9 Mon Sep 17 00:00:00 2001 From: jasquat Date: Mon, 12 Dec 2022 15:36:03 -0500 Subject: [PATCH] pyl --- .../models/spec_reference.py | 2 +- .../routes/process_api_blueprint.py | 23 ++++++++++++++----- .../services/git_service.py | 5 +++- .../integration/test_process_api.py | 9 +++++--- .../unit/test_git_service.py | 8 +++++-- 5 files changed, 34 insertions(+), 13 deletions(-) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/models/spec_reference.py b/spiffworkflow-backend/src/spiffworkflow_backend/models/spec_reference.py index ac2e3200..50b73fba 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/models/spec_reference.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/models/spec_reference.py @@ -9,7 +9,7 @@ from sqlalchemy import UniqueConstraint class SpecReferenceNotFoundError(Exception): - pass + """SpecReferenceNotFoundError.""" @dataclass() diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py index 3a73098f..0093c62e 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py @@ -65,7 +65,8 @@ from spiffworkflow_backend.models.process_model import ProcessModelInfo from spiffworkflow_backend.models.process_model import ProcessModelInfoSchema from spiffworkflow_backend.models.secret_model import SecretModel from spiffworkflow_backend.models.secret_model import SecretModelSchema -from spiffworkflow_backend.models.spec_reference import SpecReferenceCache, SpecReferenceNotFoundError +from spiffworkflow_backend.models.spec_reference import SpecReferenceCache +from spiffworkflow_backend.models.spec_reference import SpecReferenceNotFoundError from spiffworkflow_backend.models.spec_reference import SpecReferenceSchema from spiffworkflow_backend.models.spiff_logging import SpiffLoggingModel from spiffworkflow_backend.models.spiff_step_details import SpiffStepDetailsModel @@ -1073,7 +1074,9 @@ def process_instance_report_column_list() -> flask.wrappers.Response: def process_instance_show( - modified_process_model_identifier: str, process_instance_id: int, process_identifier: Optional[str] = None + modified_process_model_identifier: str, + process_instance_id: int, + process_identifier: Optional[str] = None, ) -> flask.wrappers.Response: """Create_process_instance.""" process_model_identifier = modified_process_model_identifier.replace(":", "/") @@ -1083,11 +1086,17 @@ def process_instance_show( process_model_with_diagram = None name_of_file_with_diagram = None if process_identifier: - spec_reference = SpecReferenceCache.query.filter_by(identifier=process_identifier).first() + spec_reference = SpecReferenceCache.query.filter_by( + identifier=process_identifier + ).first() if spec_reference is None: - raise SpecReferenceNotFoundError(f"Could not find given process identifier in the cache: {process_identifier}") + raise SpecReferenceNotFoundError( + f"Could not find given process identifier in the cache: {process_identifier}" + ) - process_model_with_diagram = ProcessModelService.get_process_model(spec_reference.process_model_id) + process_model_with_diagram = ProcessModelService.get_process_model( + spec_reference.process_model_id + ) name_of_file_with_diagram = spec_reference.file_name else: process_model_with_diagram = get_process_model(process_model_identifier) @@ -1104,7 +1113,9 @@ def process_instance_show( ).decode("utf-8") else: bpmn_xml_file_contents = GitService.get_instance_file_contents_for_revision( - process_model_with_diagram, process_instance.bpmn_version_control_identifier, file_name=name_of_file_with_diagram + process_model_with_diagram, + process_instance.bpmn_version_control_identifier, + file_name=name_of_file_with_diagram, ) process_instance.bpmn_xml_file_contents = bpmn_xml_file_contents diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/git_service.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/git_service.py index 519510e7..152aab1c 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/git_service.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/git_service.py @@ -46,7 +46,10 @@ class GitService: @classmethod def get_instance_file_contents_for_revision( - cls, process_model: ProcessModelInfo, revision: str, file_name: Optional[str] = None + cls, + process_model: ProcessModelInfo, + revision: str, + file_name: Optional[str] = None, ) -> str: """Get_instance_file_contents_for_revision.""" bpmn_spec_absolute_dir = current_app.config["BPMN_SPEC_ABSOLUTE_DIR"] diff --git a/spiffworkflow-backend/tests/spiffworkflow_backend/integration/test_process_api.py b/spiffworkflow-backend/tests/spiffworkflow_backend/integration/test_process_api.py index 25cd3da2..4a0100d3 100644 --- a/spiffworkflow-backend/tests/spiffworkflow_backend/integration/test_process_api.py +++ b/spiffworkflow-backend/tests/spiffworkflow_backend/integration/test_process_api.py @@ -1174,6 +1174,7 @@ class TestProcessApi(BaseTest): with_db_and_bpmn_file_cleanup: None, with_super_admin_user: UserModel, ) -> None: + """Test_process_instance_show_with_specified_process_identifier.""" process_model_id = "call_activity_nested" process_model_identifier = self.create_group_and_model_with_bpmn( client=client, @@ -1182,7 +1183,9 @@ class TestProcessApi(BaseTest): process_model_id=process_model_id, bpmn_file_location="call_activity_nested", ) - spec_reference = SpecReferenceCache.query.filter_by(identifier="Level2b").first() + spec_reference = SpecReferenceCache.query.filter_by( + identifier="Level2b" + ).first() assert spec_reference modified_process_model_identifier = ( self.modify_process_identifier_for_path_param(process_model_identifier) @@ -1211,8 +1214,8 @@ class TestProcessApi(BaseTest): with open(process_instance_file_path) as f_open: xml_file_contents = f_open.read() assert show_response.json["bpmn_xml_file_contents"] != xml_file_contents - spec_reference_file_path = ( - os.path.join(file_system_root, spec_reference.relative_path) + spec_reference_file_path = os.path.join( + file_system_root, spec_reference.relative_path ) with open(spec_reference_file_path) as f_open: xml_file_contents = f_open.read() diff --git a/spiffworkflow-backend/tests/spiffworkflow_backend/unit/test_git_service.py b/spiffworkflow-backend/tests/spiffworkflow_backend/unit/test_git_service.py index ad3c814f..ed1e24e1 100644 --- a/spiffworkflow-backend/tests/spiffworkflow_backend/unit/test_git_service.py +++ b/spiffworkflow-backend/tests/spiffworkflow_backend/unit/test_git_service.py @@ -7,6 +7,7 @@ from spiffworkflow_backend.services.git_service import GitService class TestGitService(BaseTest): + """TestGitService.""" def test_strips_output_of_stdout_from_command( self, @@ -14,5 +15,8 @@ class TestGitService(BaseTest): client: FlaskClient, with_db_and_bpmn_file_cleanup: None, ) -> None: - output = GitService.run_shell_command_to_get_stdout(["echo", ' This output should not end in space or newline \n']) - assert output == 'This output should not end in space or newline' + """Test_strips_output_of_stdout_from_command.""" + output = GitService.run_shell_command_to_get_stdout( + ["echo", " This output should not end in space or newline \n"] + ) + assert output == "This output should not end in space or newline"