[fix] Review + add more cases in unittest

pull/592/head
tessier 4 years ago
parent 68deaba85f
commit ffce3e9e77

@ -160,22 +160,13 @@ class Diagram:
return self.dot.pipe(format="png") return self.dot.pipe(format="png")
def _validate_direction(self, direction: str) -> bool: def _validate_direction(self, direction: str) -> bool:
direction = direction.upper() return direction.upper() in self.__directions
if direction in self.__directions:
return True
return False
def _validate_curvestyle(self, curvestyle: str) -> bool: def _validate_curvestyle(self, curvestyle: str) -> bool:
curvestyle = curvestyle.lower() return curvestyle.lower() in self.__curvestyles
if curvestyle in self.__curvestyles:
return True
return False
def _validate_outformat(self, outformat: str) -> bool: def _validate_outformat(self, outformat: str) -> bool:
outformat = outformat.lower() return outformat.lower() in self.__outformats
if outformat in self.__outformats:
return True
return False
def node(self, nodeid: str, label: str, **attrs) -> None: def node(self, nodeid: str, label: str, **attrs) -> None:
"""Create a new node.""" """Create a new node."""

@ -25,7 +25,7 @@ class DiagramTest(unittest.TestCase):
def test_validate_direction(self): def test_validate_direction(self):
# Normal directions. # Normal directions.
for dir in ("TB", "BT", "LR", "RL"): for dir in ("TB", "BT", "LR", "RL", "tb"):
Diagram(direction=dir) Diagram(direction=dir)
# Invalid directions. # Invalid directions.
@ -35,7 +35,7 @@ class DiagramTest(unittest.TestCase):
def test_validate_curvestyle(self): def test_validate_curvestyle(self):
# Normal directions. # Normal directions.
for cvs in ("ortho", "curved"): for cvs in ("ortho", "curved", "CURVED"):
Diagram(curvestyle=cvs) Diagram(curvestyle=cvs)
# Invalid directions. # Invalid directions.
@ -45,7 +45,7 @@ class DiagramTest(unittest.TestCase):
def test_validate_outformat(self): def test_validate_outformat(self):
# Normal output formats. # Normal output formats.
for fmt in ("png", "jpg", "svg", "pdf"): for fmt in ("png", "jpg", "svg", "pdf", "PNG"):
Diagram(outformat=fmt) Diagram(outformat=fmt)
# Invalid output formats. # Invalid output formats.

Loading…
Cancel
Save