ran poet pre to delint and added type hints to fix poet mypy

This commit is contained in:
burnettk 2022-09-29 10:19:31 -04:00
parent 4905d40876
commit e8a34eb830
4 changed files with 29 additions and 27 deletions

View File

@ -376,8 +376,9 @@ class ProcessInstanceService:
return data return data
@staticmethod @staticmethod
def create_dot_dict(data: dict) -> Any: def create_dot_dict(data: dict) -> dict[str, Any]:
dot_dict = {} """Create_dot_dict."""
dot_dict: dict[str, Any] = {}
for key, value in data.items(): for key, value in data.items():
ProcessInstanceService.set_dot_value(key, value, dot_dict) ProcessInstanceService.set_dot_value(key, value, dot_dict)
return dot_dict return dot_dict

View File

@ -5,9 +5,9 @@
"required": [ "required": [
"invoice.contributorName", "invoice.contributorName",
"invoice.contributorId", "invoice.contributorId",
"invoice.invoiceId", "invoice.invoiceId",
"invoice.invoiceAmount", "invoice.invoiceAmount",
"invoice.dueDate" "invoice.dueDate"
], ],
"properties": { "properties": {
"invoice.contributorName": { "invoice.contributorName": {
@ -17,7 +17,7 @@
"invoice.contributorId": { "invoice.contributorId": {
"type": "integer", "type": "integer",
"title": "Contributor Id", "title": "Contributor Id",
"minLength": 2 "minLength": 2
}, },
"invoice.invoiceId": { "invoice.invoiceId": {
"type": "integer", "type": "integer",
@ -33,4 +33,4 @@
"title": "Due Date" "title": "Due Date"
} }
} }
} }

View File

@ -16,4 +16,4 @@
"invoice.dueDate": { "invoice.dueDate": {
"ui:widget": "date" "ui:widget": "date"
} }
} }

View File

@ -3,8 +3,12 @@ from flask.app import Flask
from tests.spiffworkflow_backend.helpers.base_test import BaseTest from tests.spiffworkflow_backend.helpers.base_test import BaseTest
from tests.spiffworkflow_backend.helpers.test_data import load_test_spec from tests.spiffworkflow_backend.helpers.test_data import load_test_spec
from spiffworkflow_backend.services.process_instance_processor import ProcessInstanceProcessor from spiffworkflow_backend.services.process_instance_processor import (
from spiffworkflow_backend.services.process_instance_service import ProcessInstanceService ProcessInstanceProcessor,
)
from spiffworkflow_backend.services.process_instance_service import (
ProcessInstanceService,
)
class TestDotNotation(BaseTest): class TestDotNotation(BaseTest):
@ -13,11 +17,11 @@ class TestDotNotation(BaseTest):
def test_dot_notation( def test_dot_notation(
self, app: Flask, with_db_and_bpmn_file_cleanup: None self, app: Flask, with_db_and_bpmn_file_cleanup: None
) -> None: ) -> None:
"""Test_form_data_conversion_to_dot_dict""" """Test_form_data_conversion_to_dot_dict."""
process_model = load_test_spec( process_model = load_test_spec(
"test_dot_notation", "test_dot_notation",
bpmn_file_name="diagram.bpmn", bpmn_file_name="diagram.bpmn",
process_model_source_directory="dot_notation" process_model_source_directory="dot_notation",
) )
current_user = self.find_or_create_user() current_user = self.find_or_create_user()
@ -30,26 +34,23 @@ class TestDotNotation(BaseTest):
user_task = processor.get_ready_user_tasks()[0] user_task = processor.get_ready_user_tasks()[0]
form_data = { form_data = {
'invoice.contibutorName': 'Elizabeth', "invoice.contibutorName": "Elizabeth",
'invoice.contributorId': 100, "invoice.contributorId": 100,
'invoice.invoiceId': 10001, "invoice.invoiceId": 10001,
'invoice.invoiceAmount': '1000.00', "invoice.invoiceAmount": "1000.00",
'invoice.dueDate': '09/30/2022', "invoice.dueDate": "09/30/2022",
} }
ProcessInstanceService.complete_form_task( ProcessInstanceService.complete_form_task(
processor, processor, user_task, form_data, current_user
user_task,
form_data,
current_user
) )
expected = { expected = {
'contibutorName': 'Elizabeth', "contibutorName": "Elizabeth",
'contributorId': 100, "contributorId": 100,
'invoiceId': 10001, "invoiceId": 10001,
'invoiceAmount': '1000.00', "invoiceAmount": "1000.00",
'dueDate': '09/30/2022', "dueDate": "09/30/2022",
} }
processor.do_engine_steps(save=True) processor.do_engine_steps(save=True)
assert processor.get_data()['invoice'] == expected assert processor.get_data()["invoice"] == expected