Skip to content

Commit

Permalink
Fix legacy flow (jsocol#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
maxime-fender authored and thomas-desforges committed Mar 31, 2022
1 parent 9b0f440 commit abe0918
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 23 deletions.
24 changes: 11 additions & 13 deletions tests/adapters/flow_validation/test_flow_validation_success.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def test_working_flow_is_loaded( # pylint: disable=too-many-locals
],
with_csat=True,
has_go_back_quick_reply=False,
is_deflection=True,
)
check_go_to_flow_node(
node=nodes[1],
Expand All @@ -110,6 +111,7 @@ def test_working_flow_is_loaded( # pylint: disable=too-many-locals
image_slots=[],
with_csat=False,
has_go_back_quick_reply=True,
is_deflection=False,
)
check_agent_handover_node(
node=nodes[4],
Expand All @@ -132,6 +134,7 @@ def test_working_flow_is_loaded( # pylint: disable=too-many-locals
image_slots=[],
with_csat=False,
has_go_back_quick_reply=True,
is_deflection=False,
)

assert len(flow.edges) == 6
Expand Down Expand Up @@ -203,10 +206,7 @@ def test_working_flow_is_loaded( # pylint: disable=too-many-locals
flow.edges[5],
source=user_input_uuid,
target=third_answer_node_uuid,
data={
"type": EdgeTypes.direct_link,
"uuid": edge_to_third_answer_uuid,
},
data={"type": EdgeTypes.direct_link, "uuid": edge_to_third_answer_uuid},
)


Expand Down Expand Up @@ -262,6 +262,7 @@ def test_working_legacy_flow_is_loaded( # pylint: disable=too-many-locals
],
with_csat=True,
has_go_back_quick_reply=False,
is_deflection=False,
)
check_go_to_flow_node(
node=nodes[1],
Expand All @@ -281,6 +282,7 @@ def test_working_legacy_flow_is_loaded( # pylint: disable=too-many-locals
image_slots=[],
with_csat=False,
has_go_back_quick_reply=True,
is_deflection=False,
)
check_agent_handover_node(
node=nodes[4],
Expand All @@ -303,6 +305,7 @@ def test_working_legacy_flow_is_loaded( # pylint: disable=too-many-locals
image_slots=[],
with_csat=False,
has_go_back_quick_reply=True,
is_deflection=False,
)

assert len(flow.edges) == 6
Expand Down Expand Up @@ -374,10 +377,7 @@ def test_working_legacy_flow_is_loaded( # pylint: disable=too-many-locals
flow.edges[5],
source=user_input_uuid,
target=third_answer_node_uuid,
data={
"type": EdgeTypes.direct_link,
"uuid": edge_to_third_answer_uuid,
},
data={"type": EdgeTypes.direct_link, "uuid": edge_to_third_answer_uuid},
)


Expand All @@ -389,17 +389,14 @@ def check_answer_node( # pylint: disable=too-many-locals
image_slots: list[dict[str, dict]],
with_csat: bool,
has_go_back_quick_reply: bool,
is_deflection: bool,
) -> None:
assert node.type == NodeTypes.answer
assert node.uuid == node_uuid
answer_data = node.data
assert isinstance(answer_data, AnswerData)

for actual_bubble, bubble in zip(
answer_data.bubbles,
bubbles,
strict=True,
):
for actual_bubble, bubble in zip(answer_data.bubbles, bubbles, strict=True):

assert actual_bubble.delay_seconds == bubble["delay_seconds"]

Expand Down Expand Up @@ -446,6 +443,7 @@ def check_answer_node( # pylint: disable=too-many-locals

assert answer_data.with_csat == with_csat
assert answer_data.has_go_back_quick_reply == has_go_back_quick_reply
assert answer_data.is_deflection == is_deflection


def check_go_to_flow_node(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def test_working_flow_is_loaded( # pylint: disable=too-many-locals
],
with_csat=True,
has_go_back_quick_reply=False,
is_deflection=True,
)
check_go_to_flow_node(
node=nodes[1],
Expand All @@ -106,6 +107,7 @@ def test_working_flow_is_loaded( # pylint: disable=too-many-locals
image_slots=[],
with_csat=False,
has_go_back_quick_reply=True,
is_deflection=False,
)
check_agent_handover_node(
node=nodes[4],
Expand All @@ -128,6 +130,7 @@ def test_working_flow_is_loaded( # pylint: disable=too-many-locals
image_slots=[],
with_csat=False,
has_go_back_quick_reply=True,
is_deflection=False,
)

assert len(flow.edges) == 6
Expand Down Expand Up @@ -199,10 +202,7 @@ def test_working_flow_is_loaded( # pylint: disable=too-many-locals
flow.edges[5],
source=user_input_uuid,
target=third_answer_node_uuid,
data={
"type": EdgeTypes.direct_link,
"uuid": edge_to_third_answer_uuid,
},
data={"type": EdgeTypes.direct_link, "uuid": edge_to_third_answer_uuid},
)


Expand Down Expand Up @@ -236,6 +236,7 @@ def test_working_legacy_flow_is_loaded(
image_slots=[],
with_csat=False,
has_go_back_quick_reply=False,
is_deflection=False,
)
check_go_to_flow_node(
node=nodes[1],
Expand All @@ -255,6 +256,7 @@ def test_working_legacy_flow_is_loaded(
image_slots=[],
with_csat=False,
has_go_back_quick_reply=False,
is_deflection=False,
)

assert len(flow.edges) == 3
Expand Down Expand Up @@ -307,6 +309,7 @@ def check_answer_node( # pylint: disable=too-many-locals
image_slots: list[dict[str, dict]],
with_csat: bool,
has_go_back_quick_reply: bool,
is_deflection: bool,
) -> None:
assert node.type == NodeTypes.answer
assert node.uuid == node_uuid
Expand Down Expand Up @@ -341,6 +344,7 @@ def check_answer_node( # pylint: disable=too-many-locals

assert answer_data.with_csat == with_csat
assert answer_data.has_go_back_quick_reply == has_go_back_quick_reply
assert answer_data.is_deflection == is_deflection


def check_go_to_flow_node(
Expand Down
6 changes: 0 additions & 6 deletions tests/fixtures/valid_flow_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,6 @@ def legacy_reference_flow( # pylint: disable=too-many-arguments, too-many-local
],
"with_csat": True,
"has_go_back_quick_reply": False,
"is_deflection": True,
},
},
{
Expand Down Expand Up @@ -542,7 +541,6 @@ def legacy_reference_flow( # pylint: disable=too-many-arguments, too-many-local
"image_slots": [],
"with_csat": False,
"has_go_back_quick_reply": True,
"is_deflection": False,
},
},
{
Expand Down Expand Up @@ -603,7 +601,6 @@ def legacy_reference_flow( # pylint: disable=too-many-arguments, too-many-local
"image_slots": [],
"with_csat": False,
"has_go_back_quick_reply": True,
"is_deflection": False,
},
},
],
Expand Down Expand Up @@ -674,7 +671,4 @@ def legacy_reference_flow( # pylint: disable=too-many-arguments, too-many-local
],
}

assert flow == reference_flow # NB: currently it is the same as the reference flow
# as there is no accepted legacy in v0.2. In case of change, drop this assert and this comment

return flow

0 comments on commit abe0918

Please sign in to comment.