From 228a2b196e82bb270e659b869a37210c14c09358 Mon Sep 17 00:00:00 2001 From: hanhxiao Date: Mon, 14 Oct 2019 15:36:29 +0800 Subject: [PATCH] fix(flow): fix unit test assert in flow --- gnes/flow/__init__.py | 17 +++++------------ tests/test_gnes_flow.py | 4 ++-- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/gnes/flow/__init__.py b/gnes/flow/__init__.py index b7372f4c..8470bb0e 100644 --- a/gnes/flow/__init__.py +++ b/gnes/flow/__init__.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 diff --git a/tests/test_gnes_flow.py b/tests/test_gnes_flow.py index 39aa49cd..8bdad805 100644 --- a/tests/test_gnes_flow.py +++ b/tests/test_gnes_flow.py @@ -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)