From 294bc8f205e8e4823d06978ec9856f74bb61bc84 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Sun, 25 Jul 2021 23:30:45 +0300 Subject: [PATCH] unit test for pydot --- tests/unit/test_pydot.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 tests/unit/test_pydot.py diff --git a/tests/unit/test_pydot.py b/tests/unit/test_pydot.py new file mode 100644 index 000000000..9f51bf531 --- /dev/null +++ b/tests/unit/test_pydot.py @@ -0,0 +1,32 @@ +# -*- coding: UTF-8 -* + +"""Unit tests for pydot + +Ce test vérifie que le module pydot est compatible avec notre code. +(pydot a souyvent été buggué) + +Usage: pytest tests/unit/test_pydot.py +""" + +import pydot +from app.scodoc import sco_utils as scu + + +def test_pydot(test_client): + g = pydot.Dot("graphname") + g.add_node(pydot.Node("a")) + g.add_node(pydot.Node("b")) + n = g.get_node("a") + assert isinstance(n, list) + assert len(n) == 1 + assert [x.get_name() for x in g.get_node_list()] == ["a", "b"] + # + edges = [("a", "b"), ("b", "c"), ("c", "d")] + g = scu.graph_from_edges(edges) + assert len(g.get_node_list()) == 4 + n = g.get_node("d")[0] + n.set_fontname("Helvetica") + n.set_fontsize(8.0) + n.set("label", "toto") + assert "fontname=Helvetica" in g.to_string() + assert "toto" in g.to_string()