Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions tests/test_mermaid.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,26 @@ def test_roi_parallel_deeper(self):
self.assertEqual(len(edges), 2)
self.assertEqual(len(nodes), 10)

def test_transitions_without_labels_between_outer_states(self):
states = [
'A', 'B',
{'name': 'C',
'parallel': [
{'name': '1', 'children': ['a', {'name': 'b', 'final': True}],
'initial': 'a', 'transitions': [['go', 'a', 'b']]},
{'name': '2', 'children': ['a', {'name': 'b', 'final': True}],
'initial': 'a', 'transitions': [['go', 'a', 'b']]}
]}
]
transitions = [['', 'C', 'A'], ['', 'A', 'B'], ['', 'B', 'C']]
machine = self.machine_cls(states=states, transitions=transitions, initial='A',
graph_engine=self.graph_engine)
dot = machine.get_graph().source

self.assertIn('C --> A', dot)
self.assertIn('A --> B', dot)
self.assertIn('B --> C', dot)


class TestDiagramsLockedNested(TestDiagramsNested):

Expand Down
7 changes: 4 additions & 3 deletions transitions/extensions/diagrams_mermaid.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,10 @@ def _add_edges(self, transitions, container):

for src, dests in edges_attr.items():
for dst, attr in dests.items():
if not attr["label"]:
continue
container.append("{source} --> {dest}: {label}".format(**attr))
if attr["label"]:
container.append("{source} --> {dest}: {label}".format(**attr))
else:
container.append("{source} --> {dest}".format(**attr))

def _create_edge_attr(self, src, dst, transition):
return {"source": src, "dest": dst, "label": self._transition_label(transition)}
Expand Down