Skip to content

Commit

Permalink
updated test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
csgoh committed Feb 12, 2024
1 parent ef57f0c commit bdb4735
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions src/test_text2diagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,22 @@ def prep_for_test(filename: str):
return os.path.join(path, filename)


def generate_diagram(input_syntax: str):
output_file = prep_for_test(f"{inspect.currentframe().f_back.f_code.co_name}.png")
gen_code, img = text2diagram.render(input_syntax, output_file, show_code=True)
img.save(output_file)
def generate_diagram(input_syntax: str, painter_type: str = "PNG"):
if painter_type == "PNG":
output_file = prep_for_test(
f"{inspect.currentframe().f_back.f_code.co_name}.png"
)
else:
output_file = prep_for_test(
f"{inspect.currentframe().f_back.f_code.co_name}.svg"
)
_, img = text2diagram.render(input_syntax, output_file, show_code=True)
if painter_type == "PNG":
img.save(output_file)
else:
# save gen_code as SVG file
with open(output_file, "w") as f:
f.write(img)


def test_text2diagram_01():
Expand Down Expand Up @@ -371,8 +383,8 @@ def test_text2diagram_14():
footer: Generated by ProcessPiper
"""

generate_diagram(input_syntax)
generate_diagram(input_syntax, "PNG")
generate_diagram(input_syntax, "SVG")


if __name__ == "__main__":
Expand All @@ -396,4 +408,4 @@ def test_text2diagram_14():
print("Thank you for using ProcessPiper!")
print("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
print("XXXXXXXXXXXXXXXXXXXXXXXX")
print("XXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
print("XXXXXXXXXXXXXXXXXXXXXXXXXXXXX")

0 comments on commit bdb4735

Please sign in to comment.