yaml2dot 2.1.0__tar.gz → 2.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {yaml2dot-2.1.0/yaml2dot.egg-info → yaml2dot-2.2.0}/PKG-INFO +12 -15
- {yaml2dot-2.1.0 → yaml2dot-2.2.0}/pyproject.toml +12 -19
- yaml2dot-2.2.0/tests/test_converter.py +148 -0
- {yaml2dot-2.1.0 → yaml2dot-2.2.0}/tests/test_data_loader.py +13 -20
- {yaml2dot-2.1.0 → yaml2dot-2.2.0}/tests/test_legacy_renderer.py +19 -15
- yaml2dot-2.2.0/tests/test_main.py +515 -0
- {yaml2dot-2.1.0 → yaml2dot-2.2.0}/tests/test_renderer.py +20 -9
- yaml2dot-2.2.0/tests/test_security.py +96 -0
- {yaml2dot-2.1.0 → yaml2dot-2.2.0}/yaml2dot/__main__.py +50 -35
- {yaml2dot-2.1.0 → yaml2dot-2.2.0}/yaml2dot/converter.py +22 -20
- {yaml2dot-2.1.0 → yaml2dot-2.2.0}/yaml2dot/data_loader.py +11 -11
- {yaml2dot-2.1.0 → yaml2dot-2.2.0}/yaml2dot/legacy_renderer.py +25 -14
- yaml2dot-2.2.0/yaml2dot/renderer.py +256 -0
- {yaml2dot-2.1.0 → yaml2dot-2.2.0/yaml2dot.egg-info}/PKG-INFO +12 -15
- {yaml2dot-2.1.0 → yaml2dot-2.2.0}/yaml2dot.egg-info/SOURCES.txt +1 -14
- yaml2dot-2.2.0/yaml2dot.egg-info/requires.txt +14 -0
- yaml2dot-2.2.0/yaml2dot.egg-info/top_level.txt +1 -0
- yaml2dot-2.1.0/tests/generate_large_graph.py +0 -26
- yaml2dot-2.1.0/tests/test_converter.py +0 -115
- yaml2dot-2.1.0/tests/test_main.py +0 -464
- yaml2dot-2.1.0/venv/bin/rst2html.py +0 -23
- yaml2dot-2.1.0/venv/bin/rst2html4.py +0 -26
- yaml2dot-2.1.0/venv/bin/rst2html5.py +0 -33
- yaml2dot-2.1.0/venv/bin/rst2latex.py +0 -26
- yaml2dot-2.1.0/venv/bin/rst2man.py +0 -27
- yaml2dot-2.1.0/venv/bin/rst2odt.py +0 -28
- yaml2dot-2.1.0/venv/bin/rst2odt_prepstyles.py +0 -20
- yaml2dot-2.1.0/venv/bin/rst2pseudoxml.py +0 -23
- yaml2dot-2.1.0/venv/bin/rst2s5.py +0 -24
- yaml2dot-2.1.0/venv/bin/rst2xetex.py +0 -27
- yaml2dot-2.1.0/venv/bin/rst2xml.py +0 -23
- yaml2dot-2.1.0/venv/bin/rstpep2html.py +0 -25
- yaml2dot-2.1.0/yaml2dot/__init__.py +0 -0
- yaml2dot-2.1.0/yaml2dot/renderer.py +0 -160
- yaml2dot-2.1.0/yaml2dot.egg-info/requires.txt +0 -18
- yaml2dot-2.1.0/yaml2dot.egg-info/top_level.txt +0 -6
- {yaml2dot-2.1.0 → yaml2dot-2.2.0}/LICENSE +0 -0
- {yaml2dot-2.1.0 → yaml2dot-2.2.0}/README.md +0 -0
- {yaml2dot-2.1.0 → yaml2dot-2.2.0}/setup.cfg +0 -0
- {yaml2dot-2.1.0/tests → yaml2dot-2.2.0/yaml2dot}/__init__.py +0 -0
- {yaml2dot-2.1.0 → yaml2dot-2.2.0}/yaml2dot.egg-info/dependency_links.txt +0 -0
- {yaml2dot-2.1.0 → yaml2dot-2.2.0}/yaml2dot.egg-info/entry_points.txt +0 -0
|
@@ -1,35 +1,32 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: yaml2dot
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.2.0
|
|
4
4
|
Summary: Python Yaml to Dot Converter
|
|
5
5
|
Author-email: Adrian Martinez <afmartinez1215@gmail.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/AdrianMartinezCodes/pythonYaml2Dot
|
|
7
7
|
Project-URL: Repository, https://github.com/AdrianMartinezCodes/pythonYaml2Dot.git
|
|
8
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
9
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
10
8
|
Classifier: Programming Language :: Python :: 3.10
|
|
11
9
|
Classifier: Programming Language :: Python :: 3.11
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
12
13
|
Classifier: License :: OSI Approved :: MIT License
|
|
13
14
|
Classifier: Operating System :: OS Independent
|
|
14
|
-
Requires-Python: >=3.
|
|
15
|
+
Requires-Python: >=3.10
|
|
15
16
|
Description-Content-Type: text/markdown
|
|
16
17
|
License-File: LICENSE
|
|
17
|
-
Requires-Dist: PyYAML
|
|
18
|
-
Requires-Dist: networkx
|
|
19
|
-
Requires-Dist: click
|
|
20
|
-
Requires-Dist: pydot
|
|
18
|
+
Requires-Dist: PyYAML>=6.0
|
|
19
|
+
Requires-Dist: networkx>=3.4
|
|
20
|
+
Requires-Dist: click>=8.1
|
|
21
|
+
Requires-Dist: pydot>=3.0.1
|
|
21
22
|
Provides-Extra: dev
|
|
22
|
-
Requires-Dist:
|
|
23
|
-
Requires-Dist: flake8; extra == "dev"
|
|
24
|
-
Requires-Dist: yapf; extra == "dev"
|
|
25
|
-
Requires-Dist: isort; extra == "dev"
|
|
26
|
-
Requires-Dist: mypy; extra == "dev"
|
|
23
|
+
Requires-Dist: ruff; extra == "dev"
|
|
27
24
|
Provides-Extra: test
|
|
28
25
|
Requires-Dist: pytest; extra == "test"
|
|
29
26
|
Requires-Dist: coverage; extra == "test"
|
|
30
|
-
Requires-Dist: networkx; extra == "test"
|
|
31
27
|
Provides-Extra: all
|
|
32
28
|
Requires-Dist: yaml2dot[dev,test]; extra == "all"
|
|
29
|
+
Dynamic: license-file
|
|
33
30
|
|
|
34
31
|
# Yaml2Dot
|
|
35
32
|
|
|
@@ -4,25 +4,26 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "yaml2dot"
|
|
7
|
-
version='2.
|
|
7
|
+
version='2.2.0'
|
|
8
8
|
description= 'Python Yaml to Dot Converter'
|
|
9
|
-
requires-python= '>=3.
|
|
9
|
+
requires-python= '>=3.10'
|
|
10
10
|
authors = [
|
|
11
11
|
{name="Adrian Martinez", email="afmartinez1215@gmail.com"}]
|
|
12
12
|
readme = "README.md"
|
|
13
13
|
classifiers = [
|
|
14
|
-
"Programming Language :: Python :: 3.8",
|
|
15
|
-
"Programming Language :: Python :: 3.9",
|
|
16
14
|
"Programming Language :: Python :: 3.10",
|
|
17
15
|
"Programming Language :: Python :: 3.11",
|
|
16
|
+
"Programming Language :: Python :: 3.12",
|
|
17
|
+
"Programming Language :: Python :: 3.13",
|
|
18
|
+
"Programming Language :: Python :: 3.14",
|
|
18
19
|
"License :: OSI Approved :: MIT License",
|
|
19
20
|
"Operating System :: OS Independent",
|
|
20
21
|
]
|
|
21
22
|
dependencies = [
|
|
22
|
-
"PyYAML",
|
|
23
|
-
"networkx",
|
|
24
|
-
"click",
|
|
25
|
-
"pydot"
|
|
23
|
+
"PyYAML>=6.0",
|
|
24
|
+
"networkx>=3.4",
|
|
25
|
+
"click>=8.1",
|
|
26
|
+
"pydot>=3.0.1",
|
|
26
27
|
]
|
|
27
28
|
|
|
28
29
|
|
|
@@ -32,33 +33,25 @@ Repository = "https://github.com/AdrianMartinezCodes/pythonYaml2Dot.git"
|
|
|
32
33
|
|
|
33
34
|
[project.optional-dependencies]
|
|
34
35
|
dev = [
|
|
35
|
-
|
|
36
|
-
"flake8",
|
|
37
|
-
"yapf",
|
|
38
|
-
"isort",
|
|
39
|
-
"mypy"
|
|
36
|
+
"ruff",
|
|
40
37
|
]
|
|
41
38
|
test = [
|
|
42
39
|
"pytest",
|
|
43
40
|
"coverage",
|
|
44
|
-
"networkx"
|
|
45
41
|
]
|
|
46
42
|
all = [
|
|
47
43
|
"yaml2dot[dev,test]"
|
|
48
44
|
]
|
|
49
45
|
|
|
50
46
|
[tool.setuptools.packages]
|
|
51
|
-
find = {}
|
|
47
|
+
find = { include = ["yaml2dot*"] }
|
|
52
48
|
|
|
53
49
|
[tool.coverage.run]
|
|
54
50
|
omit = ["tests/*"]
|
|
55
51
|
|
|
56
52
|
[tool.pytest.ini_options]
|
|
57
|
-
asyncio_mode = "auto"
|
|
58
|
-
env_files = [".env.example"]
|
|
59
53
|
testpaths = ["tests"]
|
|
60
|
-
[
|
|
61
|
-
pythonpath = "."
|
|
54
|
+
pythonpath = ["."]
|
|
62
55
|
|
|
63
56
|
[project.scripts]
|
|
64
57
|
yaml2dot = "yaml2dot.__main__:render_yaml"
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
from yaml2dot.converter import convert_yaml_or_json_to_format
|
|
2
|
+
|
|
3
|
+
# Define sample YAML and JSON data for testing
|
|
4
|
+
sample_yaml_data = {
|
|
5
|
+
"key1": "value1",
|
|
6
|
+
"key2": {"nested_key": "nested_value"},
|
|
7
|
+
"key3": [1, 2, 3],
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
sample_json_data = {
|
|
11
|
+
"nodes": [{"id": "A", "label": "Node A"}, {"id": "B", "label": "Node B"}],
|
|
12
|
+
"links": [{"source": "A", "target": "B"}, {"source": "B", "target": "A"}],
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def test_convert_yaml_to_dot():
|
|
17
|
+
dot_output = convert_yaml_or_json_to_format(
|
|
18
|
+
sample_yaml_data,
|
|
19
|
+
output_format="dot",
|
|
20
|
+
multi_view=False,
|
|
21
|
+
round_robin=False,
|
|
22
|
+
shape="rounded",
|
|
23
|
+
)
|
|
24
|
+
assert dot_output is not None
|
|
25
|
+
assert isinstance(dot_output, str)
|
|
26
|
+
assert "shape=rounded" in dot_output
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def test_convert_yaml_to_json():
|
|
30
|
+
json_output = convert_yaml_or_json_to_format(sample_yaml_data, output_format="json")
|
|
31
|
+
assert json_output is not None
|
|
32
|
+
assert isinstance(json_output, str)
|
|
33
|
+
assert "nodes" in json_output
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def test_convert_json_to_dot():
|
|
37
|
+
dot_output = convert_yaml_or_json_to_format(sample_json_data, output_format="dot")
|
|
38
|
+
assert dot_output is not None
|
|
39
|
+
assert isinstance(dot_output, str)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def test_convert_json_to_json():
|
|
43
|
+
json_output = convert_yaml_or_json_to_format(sample_json_data, output_format="json")
|
|
44
|
+
assert json_output is not None
|
|
45
|
+
assert isinstance(json_output, str)
|
|
46
|
+
assert "nodes" in json_output
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def test_invalid_output_format():
|
|
50
|
+
invalid_output = convert_yaml_or_json_to_format(
|
|
51
|
+
sample_yaml_data, output_format="invalid_format"
|
|
52
|
+
)
|
|
53
|
+
assert invalid_output is None
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def test_invalid_data():
|
|
57
|
+
invalid_data = "key1: value1, key2: value2"
|
|
58
|
+
dot_output = convert_yaml_or_json_to_format(invalid_data, output_format="dot")
|
|
59
|
+
json_output = convert_yaml_or_json_to_format(invalid_data, output_format="json")
|
|
60
|
+
assert dot_output is None
|
|
61
|
+
assert json_output is None
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def test_convert_with_custom_node_attrs():
|
|
65
|
+
custom_attrs = {"color": "red", "style": "filled"}
|
|
66
|
+
dot_output = convert_yaml_or_json_to_format(
|
|
67
|
+
sample_yaml_data, output_format="dot", user_node_attrs=custom_attrs
|
|
68
|
+
)
|
|
69
|
+
assert dot_output is not None
|
|
70
|
+
assert "color=red" in dot_output
|
|
71
|
+
assert "style=filled" in dot_output
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def test_convert_with_multi_view():
|
|
75
|
+
dot_output = convert_yaml_or_json_to_format(
|
|
76
|
+
sample_yaml_data, output_format="dot", multi_view=True
|
|
77
|
+
)
|
|
78
|
+
assert dot_output is not None
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def test_convert_with_round_robin():
|
|
82
|
+
dot_output = convert_yaml_or_json_to_format(
|
|
83
|
+
sample_yaml_data, output_format="dot", round_robin=True
|
|
84
|
+
)
|
|
85
|
+
assert dot_output is not None
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def test_convert_with_specific_shape():
|
|
89
|
+
shape = "box"
|
|
90
|
+
dot_output = convert_yaml_or_json_to_format(
|
|
91
|
+
sample_yaml_data, output_format="dot", shape=shape
|
|
92
|
+
)
|
|
93
|
+
assert dot_output is not None
|
|
94
|
+
assert "shape=box" in dot_output
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def test_read_list_inputs():
|
|
98
|
+
raw_list = [
|
|
99
|
+
{
|
|
100
|
+
"apiVersion": "v1",
|
|
101
|
+
"kind": "Namespace",
|
|
102
|
+
"metadata": {"name": "example-namespace"},
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"apiVersion": "v1",
|
|
106
|
+
"kind": "ConfigMap",
|
|
107
|
+
"metadata": {"name": "example-config", "namespace": "example-namespace"},
|
|
108
|
+
"data": {"application.properties": "property1=value1\nproperty2=value2\n"},
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"apiVersion": "apps/v1",
|
|
112
|
+
"kind": "Deployment",
|
|
113
|
+
"metadata": {
|
|
114
|
+
"name": "example-deployment",
|
|
115
|
+
"namespace": "example-namespace",
|
|
116
|
+
},
|
|
117
|
+
"spec": {
|
|
118
|
+
"replicas": 3,
|
|
119
|
+
"selector": {"matchLabels": {"app": "example"}},
|
|
120
|
+
"template": {
|
|
121
|
+
"metadata": {"labels": {"app": "example"}},
|
|
122
|
+
"spec": {
|
|
123
|
+
"containers": [
|
|
124
|
+
{
|
|
125
|
+
"name": "example-container",
|
|
126
|
+
"image": "example-image:latest",
|
|
127
|
+
"ports": [{"containerPort": 8080}],
|
|
128
|
+
"envFrom": [
|
|
129
|
+
{"configMapRef": {"name": "example-config"}}
|
|
130
|
+
],
|
|
131
|
+
}
|
|
132
|
+
]
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"apiVersion": "v1",
|
|
139
|
+
"kind": "Service",
|
|
140
|
+
"metadata": {"name": "example-service", "namespace": "example-namespace"},
|
|
141
|
+
"spec": {
|
|
142
|
+
"selector": {"app": "example"},
|
|
143
|
+
"ports": [{"protocol": "TCP", "port": 80, "targetPort": 8080}],
|
|
144
|
+
"type": "LoadBalancer",
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
]
|
|
148
|
+
assert convert_yaml_or_json_to_format(raw_list)
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import io
|
|
2
|
-
import json
|
|
3
2
|
import os
|
|
4
3
|
import tempfile
|
|
5
4
|
|
|
@@ -27,7 +26,7 @@ def test_parse_yaml(sample_yaml_content):
|
|
|
27
26
|
parsed_data, error = parse_yaml(reader)
|
|
28
27
|
|
|
29
28
|
assert error is None
|
|
30
|
-
expected = [{
|
|
29
|
+
expected = [{"key1": "value1", "key2": "value2"}]
|
|
31
30
|
assert parsed_data == expected
|
|
32
31
|
|
|
33
32
|
|
|
@@ -56,8 +55,7 @@ def temp_yaml_file():
|
|
|
56
55
|
key1: value1
|
|
57
56
|
key2: value2
|
|
58
57
|
"""
|
|
59
|
-
with tempfile.NamedTemporaryFile(delete=False, mode=
|
|
60
|
-
suffix=".yaml") as file:
|
|
58
|
+
with tempfile.NamedTemporaryFile(delete=False, mode="w", suffix=".yaml") as file:
|
|
61
59
|
file.write(content)
|
|
62
60
|
file_path = file.name
|
|
63
61
|
yield file_path
|
|
@@ -68,8 +66,7 @@ def temp_yaml_file():
|
|
|
68
66
|
def temp_json_file():
|
|
69
67
|
# Create a temporary JSON file with sample content
|
|
70
68
|
content = '{"key1": "value1", "key2": "value2"}'
|
|
71
|
-
with tempfile.NamedTemporaryFile(delete=False, mode=
|
|
72
|
-
suffix=".json") as file:
|
|
69
|
+
with tempfile.NamedTemporaryFile(delete=False, mode="w", suffix=".json") as file:
|
|
73
70
|
file.write(content)
|
|
74
71
|
file_path = file.name
|
|
75
72
|
yield file_path
|
|
@@ -78,15 +75,14 @@ def temp_json_file():
|
|
|
78
75
|
|
|
79
76
|
def test_load_yaml_or_json_valid_json(temp_json_file):
|
|
80
77
|
data = load_yaml_or_json(temp_json_file)
|
|
81
|
-
expected = {
|
|
78
|
+
expected = {"key1": "value1", "key2": "value2"}
|
|
82
79
|
assert data == expected
|
|
83
80
|
|
|
84
81
|
|
|
85
82
|
def test_load_yaml_or_json_invalid_yaml():
|
|
86
83
|
# Simulate loading an invalid YAML file
|
|
87
84
|
invalid_yaml = "key1: value1\nkey2: value2\nkey3: value3:" # Invalid YAML
|
|
88
|
-
with tempfile.NamedTemporaryFile(delete=False, mode=
|
|
89
|
-
suffix=".yaml") as file:
|
|
85
|
+
with tempfile.NamedTemporaryFile(delete=False, mode="w", suffix=".yaml") as file:
|
|
90
86
|
file.write(invalid_yaml)
|
|
91
87
|
temp_yaml_file = file.name
|
|
92
88
|
|
|
@@ -96,9 +92,10 @@ def test_load_yaml_or_json_invalid_yaml():
|
|
|
96
92
|
|
|
97
93
|
def test_load_yaml_or_json_invalid_json():
|
|
98
94
|
# Simulate loading an invalid JSON file
|
|
99
|
-
invalid_json =
|
|
100
|
-
|
|
101
|
-
|
|
95
|
+
invalid_json = (
|
|
96
|
+
'{"key1": "value1", "key2": "value2", "key3": "value3":}' # Invalid JSON
|
|
97
|
+
)
|
|
98
|
+
with tempfile.NamedTemporaryFile(delete=False, mode="w", suffix=".json") as file:
|
|
102
99
|
file.write(invalid_json)
|
|
103
100
|
temp_json_file = file.name
|
|
104
101
|
|
|
@@ -106,14 +103,10 @@ def test_load_yaml_or_json_invalid_json():
|
|
|
106
103
|
assert data is None
|
|
107
104
|
|
|
108
105
|
|
|
109
|
-
def test_load_yaml_or_json_invalid_file_extension():
|
|
106
|
+
def test_load_yaml_or_json_invalid_file_extension(tmp_path):
|
|
110
107
|
# Simulate loading a file with an unsupported extension
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
suffix=".txt")
|
|
114
|
-
invalid_file_path = invalid_file.name
|
|
115
|
-
invalid_file.close()
|
|
108
|
+
invalid_file_path = tmp_path / "data.txt"
|
|
109
|
+
invalid_file_path.write_text("")
|
|
116
110
|
|
|
117
|
-
data = load_yaml_or_json(invalid_file_path)
|
|
111
|
+
data = load_yaml_or_json(str(invalid_file_path))
|
|
118
112
|
assert data is None
|
|
119
|
-
os.remove(invalid_file_path)
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import filecmp
|
|
2
1
|
import json
|
|
3
2
|
import tempfile
|
|
4
3
|
from pathlib import Path
|
|
@@ -7,20 +6,23 @@ import networkx as nx
|
|
|
7
6
|
import pytest
|
|
8
7
|
import yaml
|
|
9
8
|
|
|
9
|
+
from tests.dot_utils import assert_dot_equivalent
|
|
10
10
|
from yaml2dot.legacy_renderer import render
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
# Define a fixture to load example YAML or JSON files
|
|
14
|
-
@pytest.fixture(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
14
|
+
@pytest.fixture(
|
|
15
|
+
params=[
|
|
16
|
+
"complex.yaml",
|
|
17
|
+
"list.yaml",
|
|
18
|
+
"mixed.yaml",
|
|
19
|
+
"nested.yaml",
|
|
20
|
+
"simple.yaml",
|
|
21
|
+
"small_graph.yaml",
|
|
22
|
+
"large_graph.yaml",
|
|
23
|
+
"list.yaml",
|
|
24
|
+
]
|
|
25
|
+
)
|
|
24
26
|
def sample_data_file(request):
|
|
25
27
|
# Construct the full path to the example data file (YAML or JSON)
|
|
26
28
|
examples_dir = Path(__file__).resolve().parent.parent / "examples"
|
|
@@ -33,7 +35,9 @@ def sample_data_file(request):
|
|
|
33
35
|
def expected_dot_file(sample_data_file):
|
|
34
36
|
# Construct the full path to the expected DOT file in the tests directory
|
|
35
37
|
tests_dir = Path(__file__).resolve().parent
|
|
36
|
-
expected_dot_path =
|
|
38
|
+
expected_dot_path = (
|
|
39
|
+
tests_dir / "expected-dot-files-legacy" / f"{Path(sample_data_file).stem}.dot"
|
|
40
|
+
)
|
|
37
41
|
return str(expected_dot_path)
|
|
38
42
|
|
|
39
43
|
|
|
@@ -41,10 +45,10 @@ def test_render_with_example_files(sample_data_file, expected_dot_file):
|
|
|
41
45
|
# Determine whether the file is in YAML or JSON format based on its extension
|
|
42
46
|
file_extension = Path(sample_data_file).suffix.lower()
|
|
43
47
|
|
|
44
|
-
if file_extension ==
|
|
48
|
+
if file_extension == ".yaml":
|
|
45
49
|
with open(sample_data_file, "r") as data_file:
|
|
46
50
|
data = yaml.safe_load(data_file)
|
|
47
|
-
elif file_extension ==
|
|
51
|
+
elif file_extension == ".json":
|
|
48
52
|
with open(sample_data_file, "r") as data_file:
|
|
49
53
|
data = json.load(data_file)
|
|
50
54
|
else:
|
|
@@ -60,4 +64,4 @@ def test_render_with_example_files(sample_data_file, expected_dot_file):
|
|
|
60
64
|
pydot_graph.write_raw(str(output_dot_file))
|
|
61
65
|
|
|
62
66
|
# Compare the generated DOT file with the expected DOT file
|
|
63
|
-
|
|
67
|
+
assert_dot_equivalent(output_dot_file, expected_dot_file)
|