Skip to content

Commit

Permalink
Merge pull request #2198 from auslin-aot/feature/FWF-3488-export-supp…
Browse files Browse the repository at this point in the history
…ort-changes

FWF-3488: [Modified] Commented out call to capture subforms, subworkflows & dmns
  • Loading branch information
arun-s-aot authored Aug 20, 2024
2 parents bfd0b49 + 3094cb0 commit e58edcb
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 90 deletions.
26 changes: 14 additions & 12 deletions forms-flow-api/src/formsflow_api/services/form_process_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,18 +497,20 @@ def export( # pylint:disable=too-many-locals
workflows.append(workflow)
authorizations.append(self._get_authorizations(mapper.form_id, user))

forms_names, dmns, sub_workflows = self._parse_xml(
workflow["content"], user
)

for form in set(forms_names):
forms.append(
self._get_form(form, "sub", form_id=None, description=None, tenant_key=tenant_key)
)
for dmn in set(dmns):
rules.append(self._get_dmn(dmn, "sub", user))

workflows.extend(sub_workflows)
# Parse bpm xml to get subforms & workflows
# The following lines are currently commented out but may be needed for future use.
# forms_names, dmns, sub_workflows = self._parse_xml(
# workflow["content"], user
# )

# for form in set(forms_names):
# forms.append(
# self._get_form(form, "sub", form_id=None, description=None, tenant_key=tenant_key)
# )
# for dmn in set(dmns):
# rules.append(self._get_dmn(dmn, "sub", user))

# workflows.extend(sub_workflows)

return {
"forms": forms,
Expand Down
156 changes: 78 additions & 78 deletions forms-flow-api/tests/unit/api/test_form_process_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,85 +443,85 @@ def test_export(app, client, session, jwt, mock_redis_client):
assert len(response.json["authorizations"]) == 1

# Test export - with task based forms - no DMN - no subprocess
form = FormProcessMapper(
**mapper_payload("sample form2", "formconectflow", "FormConnectFlow")
)
form.save()
mapper_id = form.id
form_id = form.form_id

# Mock response
mock_response = MagicMock()
mock_response.status_code = 200
mock_response.json = {
"forms": [get_forms("sample form2", "main"), get_forms("sample form3", "sub")],
"workflows": [
get_workflows("formconectflow", "FormConnectFlow", "main", "xml")
],
"rules": [],
"authorizations": [get_authorizations(form_id)],
}
client.get.return_value = mock_response
response = get_export(client, headers, mapper_id)
assert response.status_code == 200
assert response.json is not None
assert len(response.json["forms"]) == 2
assert len(response.json["workflows"]) == 1
assert len(response.json["rules"]) == 0
assert len(response.json["authorizations"]) == 1
# form = FormProcessMapper(
# **mapper_payload("sample form2", "formconectflow", "FormConnectFlow")
# )
# form.save()
# mapper_id = form.id
# form_id = form.form_id

# # Mock response
# mock_response = MagicMock()
# mock_response.status_code = 200
# mock_response.json = {
# "forms": [get_forms("sample form2", "main"), get_forms("sample form3", "sub")],
# "workflows": [
# get_workflows("formconectflow", "FormConnectFlow", "main", "xml")
# ],
# "rules": [],
# "authorizations": [get_authorizations(form_id)],
# }
# client.get.return_value = mock_response
# response = get_export(client, headers, mapper_id)
# assert response.status_code == 200
# assert response.json is not None
# assert len(response.json["forms"]) == 2
# assert len(response.json["workflows"]) == 1
# assert len(response.json["rules"]) == 0
# assert len(response.json["authorizations"]) == 1

# Test export - with DMN- no task based forms - no subprocess
form = FormProcessMapper(
**mapper_payload("sample form2", "rulebasedflow", "RuleBasedFlow")
)
form.save()
mapper_id = form.id
form_id = form.form_id

# Mock response
mock_response = MagicMock()
mock_response.status_code = 200
mock_response.json = {
"forms": [get_forms("sample form2", "main")],
"workflows": [get_workflows("rulebasedflow", "RuleBasedFlow", "main", "xml")],
"rules": [get_dmns("dmn1", "main", "dmn xml")],
"authorizations": [get_authorizations(form_id)],
}
client.get.return_value = mock_response
response = get_export(client, headers, mapper_id)
assert response.status_code == 200
assert response.json is not None
assert len(response.json["forms"]) == 1
assert len(response.json["workflows"]) == 1
assert len(response.json["rules"]) == 1
assert len(response.json["authorizations"]) == 1
# form = FormProcessMapper(
# **mapper_payload("sample form2", "rulebasedflow", "RuleBasedFlow")
# )
# form.save()
# mapper_id = form.id
# form_id = form.form_id

# # Mock response
# mock_response = MagicMock()
# mock_response.status_code = 200
# mock_response.json = {
# "forms": [get_forms("sample form2", "main")],
# "workflows": [get_workflows("rulebasedflow", "RuleBasedFlow", "main", "xml")],
# "rules": [get_dmns("dmn1", "main", "dmn xml")],
# "authorizations": [get_authorizations(form_id)],
# }
# client.get.return_value = mock_response
# response = get_export(client, headers, mapper_id)
# assert response.status_code == 200
# assert response.json is not None
# assert len(response.json["forms"]) == 1
# assert len(response.json["workflows"]) == 1
# assert len(response.json["rules"]) == 1
# assert len(response.json["authorizations"]) == 1

# Test export - with subprocess - no DMN- no task based forms
form = FormProcessMapper(
**mapper_payload("sample form2", "subprocessflow", "SubprocessFlow")
)
form.save()
mapper_id = form.id
form_id = form.form_id

# Mock response
mock_response = MagicMock()
mock_response.status_code = 200
mock_response.json = {
"forms": [get_forms("sample form2", "main")],
"workflows": [
get_workflows("subprocessflow", "SubprocessFlow", "main", "xml"),
get_workflows("subflow1", "subflow1", "sub", "xml"),
get_workflows("subflow2", "subflow2", "sub", "xml"),
],
"rules": [],
"authorizations": [get_authorizations(form_id)],
}
client.get.return_value = mock_response
response = get_export(client, headers, mapper_id)
assert response.status_code == 200
assert response.json is not None
assert len(response.json["forms"]) == 1
assert len(response.json["workflows"]) == 3
assert len(response.json["rules"]) == 0
assert len(response.json["authorizations"]) == 1
# form = FormProcessMapper(
# **mapper_payload("sample form2", "subprocessflow", "SubprocessFlow")
# )
# form.save()
# mapper_id = form.id
# form_id = form.form_id

# # Mock response
# mock_response = MagicMock()
# mock_response.status_code = 200
# mock_response.json = {
# "forms": [get_forms("sample form2", "main")],
# "workflows": [
# get_workflows("subprocessflow", "SubprocessFlow", "main", "xml"),
# get_workflows("subflow1", "subflow1", "sub", "xml"),
# get_workflows("subflow2", "subflow2", "sub", "xml"),
# ],
# "rules": [],
# "authorizations": [get_authorizations(form_id)],
# }
# client.get.return_value = mock_response
# response = get_export(client, headers, mapper_id)
# assert response.status_code == 200
# assert response.json is not None
# assert len(response.json["forms"]) == 1
# assert len(response.json["workflows"]) == 3
# assert len(response.json["rules"]) == 0
# assert len(response.json["authorizations"]) == 1

0 comments on commit e58edcb

Please sign in to comment.