From ffce3e9e7747775f071d7ce46634daaa2d6f09a5 Mon Sep 17 00:00:00 2001 From: tessier Date: Sun, 23 Jan 2022 14:39:00 +0900 Subject: [PATCH] [fix] Review + add more cases in unittest --- diagrams/__init__.py | 15 +++------------ tests/test_diagram.py | 6 +++--- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/diagrams/__init__.py b/diagrams/__init__.py index 873a44dc..cc6b4298 100644 --- a/diagrams/__init__.py +++ b/diagrams/__init__.py @@ -160,22 +160,13 @@ class Diagram: return self.dot.pipe(format="png") def _validate_direction(self, direction: str) -> bool: - direction = direction.upper() - if direction in self.__directions: - return True - return False + return direction.upper() in self.__directions def _validate_curvestyle(self, curvestyle: str) -> bool: - curvestyle = curvestyle.lower() - if curvestyle in self.__curvestyles: - return True - return False + return curvestyle.lower() in self.__curvestyles def _validate_outformat(self, outformat: str) -> bool: - outformat = outformat.lower() - if outformat in self.__outformats: - return True - return False + return outformat.lower() in self.__outformats def node(self, nodeid: str, label: str, **attrs) -> None: """Create a new node.""" diff --git a/tests/test_diagram.py b/tests/test_diagram.py index 37d0e831..d31f439c 100644 --- a/tests/test_diagram.py +++ b/tests/test_diagram.py @@ -25,7 +25,7 @@ class DiagramTest(unittest.TestCase): def test_validate_direction(self): # Normal directions. - for dir in ("TB", "BT", "LR", "RL"): + for dir in ("TB", "BT", "LR", "RL", "tb"): Diagram(direction=dir) # Invalid directions. @@ -35,7 +35,7 @@ class DiagramTest(unittest.TestCase): def test_validate_curvestyle(self): # Normal directions. - for cvs in ("ortho", "curved"): + for cvs in ("ortho", "curved", "CURVED"): Diagram(curvestyle=cvs) # Invalid directions. @@ -45,7 +45,7 @@ class DiagramTest(unittest.TestCase): def test_validate_outformat(self): # Normal output formats. - for fmt in ("png", "jpg", "svg", "pdf"): + for fmt in ("png", "jpg", "svg", "pdf", "PNG"): Diagram(outformat=fmt) # Invalid output formats.