pyl
This commit is contained in:
parent
85be6db77c
commit
518a6e1606
|
@ -9,7 +9,7 @@ from sqlalchemy import UniqueConstraint
|
|||
|
||||
|
||||
class SpecReferenceNotFoundError(Exception):
|
||||
pass
|
||||
"""SpecReferenceNotFoundError."""
|
||||
|
||||
|
||||
@dataclass()
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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"]
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue