Skip to content
Permalink
Browse files

fix(flow): fix unit test assert in flow

  • Loading branch information...
hanxiao committed Oct 14, 2019
1 parent f6536c8 commit 228a2b196e82bb270e659b869a37210c14c09358
Showing with 7 additions and 14 deletions.
  1. +5 −12 gnes/flow/__init__.py
  2. +2 −2 tests/test_gnes_flow.py
@@ -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,
@@ -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
@@ -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):
@@ -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)

0 comments on commit 228a2b1

Please sign in to comment.
You can’t perform that action at this time.