Skip to content

Commit

Permalink
test: add test with yml file
Browse files Browse the repository at this point in the history
  • Loading branch information
CatStark committed Oct 1, 2020
1 parent 89fd650 commit 9d2c100
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
Binary file added tests/unit/flow/flow_original_yml.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 19 additions & 2 deletions tests/unit/flow/test_flow_visualization.py
@@ -1,9 +1,8 @@
import os
import numpy as np

from PIL import Image

from jina.flow import Flow
import glob


def test_visualization():
Expand All @@ -18,3 +17,21 @@ def test_visualization():
with Image.open(os.path.join(cur_dir, 'flow.jpg')) as flow_created:
assert flow_original.size == flow_created.size
np.testing.assert_array_almost_equal(flow_original, flow_created)

for i in glob.glob("*.jpg"):
os.remove(i)


def test_visualization_with_yml_file():
cur_dir = os.path.dirname(os.path.abspath(__file__))

f = Flow.load_config(os.path.join(cur_dir, '../yaml/test_flow_visualization.yml'))

f.mermaidstr_to_jpg()
with Image.open(os.path.join(cur_dir, 'flow_original_yml.jpg')) as flow_original:
with Image.open(os.path.join(cur_dir, 'flow.jpg')) as flow_created:
assert flow_original.size == flow_created.size
np.testing.assert_array_almost_equal(flow_original, flow_created)

for i in glob.glob("*.jpg"):
os.remove(i)
22 changes: 22 additions & 0 deletions tests/unit/yaml/test_flow_visualization.yml
@@ -0,0 +1,22 @@
!Flow
pods:
loader:
read_only: true
normalizer:
read_only: true
image_encoder:
read_only: true
image_vector_indexer:
read_only: true
image_kv_indexer:
needs: [gateway]
text_encoder:
timeout_ready: 600000
read_only: true
needs: [gateway]
text_indexer:
read_only: true
join_all:
uses: _merge
needs: [image_vector_indexer, image_kv_indexer, text_indexer]
read_only: true

0 comments on commit 9d2c100

Please sign in to comment.