|
|
|
@ -1,10 +1,18 @@
|
|
|
|
|
import os
|
|
|
|
|
import pathlib
|
|
|
|
|
import shutil
|
|
|
|
|
import unittest
|
|
|
|
|
import pathlib
|
|
|
|
|
|
|
|
|
|
from diagrams import Cluster, Diagram, Edge, Node
|
|
|
|
|
from diagrams import getcluster, getdiagram, setcluster, setdiagram
|
|
|
|
|
from diagrams import (
|
|
|
|
|
Cluster,
|
|
|
|
|
Diagram,
|
|
|
|
|
Edge,
|
|
|
|
|
Node,
|
|
|
|
|
getcluster,
|
|
|
|
|
getdiagram,
|
|
|
|
|
setcluster,
|
|
|
|
|
setdiagram,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DiagramTest(unittest.TestCase):
|
|
|
|
@ -103,7 +111,7 @@ class DiagramTest(unittest.TestCase):
|
|
|
|
|
|
|
|
|
|
def test_empty_name(self):
|
|
|
|
|
"""Check that providing an empty name don't crash, but save in a diagrams_image.xxx file."""
|
|
|
|
|
self.name = 'diagrams_image'
|
|
|
|
|
self.name = "diagrams_image"
|
|
|
|
|
with Diagram(show=False):
|
|
|
|
|
Node("node1")
|
|
|
|
|
self.assertTrue(os.path.exists(f"{self.name}.png"))
|
|
|
|
@ -113,10 +121,9 @@ class DiagramTest(unittest.TestCase):
|
|
|
|
|
node1 = Node("node1")
|
|
|
|
|
self.assertTrue(node1.label, "Node\nnode1")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_outformat_list(self):
|
|
|
|
|
"""Check that outformat render all the files from the list."""
|
|
|
|
|
self.name = 'diagrams_image'
|
|
|
|
|
self.name = "diagrams_image"
|
|
|
|
|
with Diagram(show=False, outformat=["dot", "png"]):
|
|
|
|
|
Node("node1")
|
|
|
|
|
# both files must exist
|
|
|
|
@ -311,7 +318,6 @@ class ResourcesTest(unittest.TestCase):
|
|
|
|
|
i.e. resources/<provider>/<type>/<image>, so check that this depth isn't
|
|
|
|
|
exceeded.
|
|
|
|
|
"""
|
|
|
|
|
resources_dir = pathlib.Path(__file__).parent.parent / 'resources'
|
|
|
|
|
max_depth = max(os.path.relpath(d, resources_dir).count(os.sep) + 1
|
|
|
|
|
for d, _, _ in os.walk(resources_dir))
|
|
|
|
|
resources_dir = pathlib.Path(__file__).parent.parent / "resources"
|
|
|
|
|
max_depth = max(os.path.relpath(d, resources_dir).count(os.sep) + 1 for d, _, _ in os.walk(resources_dir))
|
|
|
|
|
self.assertLessEqual(max_depth, 2)
|
|
|
|
|