Skip to content

Commit

Permalink
test: add tests for plot in end, plot in middle, plot twice
Browse files Browse the repository at this point in the history
  • Loading branch information
CatStark committed Oct 5, 2020
1 parent acbfceb commit 0c7b6eb
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
Binary file added tests/unit/flow/flow_original_end.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/unit/flow/flow_original_middle.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 22 additions & 1 deletion tests/unit/flow/test_flow_visualization.py
Expand Up @@ -38,4 +38,25 @@ def test_visualization_plot_in_middle(tmpdir):
with Image.open(os.path.join(cur_dir, 'flow_original_middle.jpg')) as flow_original:
with Image.open(tmpfile) as flow_created:
assert flow_original.size == flow_created.size
np.testing.assert_array_almost_equal(flow_original, flow_created)
np.testing.assert_array_almost_equal(flow_original, flow_created)


def test_visualization_plot_twice(tmpdir):
cur_dir = os.path.dirname(os.path.abspath(__file__))
tmpfile_middle = os.path.join(tmpdir, 'flow_test_middle.jpg')
tmpfile_end = os.path.join(tmpdir, 'flow_test_end.jpg')

flow = (Flow().add(name='pod_a')
.plot(output=tmpfile_middle)
.add(name='pod_b', needs='gateway')
.join(needs=['pod_a', 'pod_b']).plot(output=tmpfile_end))

with Image.open(os.path.join(cur_dir, 'flow_original_middle.jpg')) as flow_original_middle:
with Image.open(tmpfile_middle) as flow_created_middle:
assert flow_original_middle.size == flow_created_middle.size
np.testing.assert_array_almost_equal(flow_original_middle, flow_created_middle)

with Image.open(os.path.join(cur_dir, 'flow_original_end.jpg')) as flow_original_end:
with Image.open(tmpfile_end) as flow_created_end:
assert flow_original_end.size == flow_created_end.size
np.testing.assert_array_almost_equal(flow_original_end, flow_created_end)

0 comments on commit 0c7b6eb

Please sign in to comment.