Skip to content
This repository has been archived by the owner on Feb 22, 2020. It is now read-only.

Commit

Permalink
fix(flow): fix unit test assert in flow
Browse files Browse the repository at this point in the history
  • Loading branch information
hanhxiao committed Oct 14, 2019
1 parent f6536c8 commit 228a2b1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
17 changes: 5 additions & 12 deletions gnes/flow/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class Flow:
You can change this behavior by giving an argument `copy_flow=False`.
"""
_supported_orch = {'swarm', 'k8s'}

_service2parser = {
Service.Encoder: set_encoder_parser,
Service.Router: set_router_parser,
Expand Down Expand Up @@ -129,19 +129,12 @@ def __init__(self, with_frontend: bool = True, **kwargs):
self.logger.warning('with_frontend is set to False, you need to add_frontend() by yourself')

@_build_level(BuildLevel.GRAPH)
def to_yaml(self, orchestration: str) -> str:
if orchestration not in Flow._supported_orch:
raise TypeError(
'%s is not valid type of orchestration, should be one of %s' % (orchestration, Flow._supported_orch))

@staticmethod
def from_yaml(orchestration: str) -> 'Flow':
if orchestration not in Flow._supported_orch:
raise TypeError(
'%s is not valid type of orchestration, should be one of %s' % (orchestration, Flow._supported_orch))
def to_swarm_yaml(self) -> str:
swarm_yml = ''
return swarm_yml

@_build_level(BuildLevel.GRAPH)
def to_mermaid(self, left_right: bool = True):
def to_mermaid(self, left_right: bool = True) -> str:
"""
Output the mermaid graph for visualization
Expand Down
4 changes: 2 additions & 2 deletions tests/test_gnes_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import unittest

from gnes.cli.parser import set_client_cli_parser
from gnes.flow import Flow, Service as gfs, FlowBuildLevelMismatch, FlowTopologyError
from gnes.flow import Flow, Service as gfs, FlowBuildLevelMismatch


class TestGNESFlow(unittest.TestCase):
Expand Down Expand Up @@ -49,7 +49,7 @@ def test_flow1(self):
print('f: %r g: %r' % (f, g))
f.build()
print(f.to_mermaid())
self.assertRaises(FlowTopologyError, g.build)
g.build()

def test_flow1_ctx_empty(self):
f = (Flow(check_version=False, route_table=True)
Expand Down

0 comments on commit 228a2b1

Please sign in to comment.