mirror of
https://github.com/infeeeee/dyn2py
synced 2025-12-16 22:16:18 +01:00
Tests, documentation, fixes
This commit is contained in:
@@ -2,16 +2,8 @@ import unittest
|
||||
import dyn2py
|
||||
import pathlib
|
||||
|
||||
INPUT_DIR = "tests/input_files"
|
||||
OUTPUT_DIR = "tests/output_files"
|
||||
from tests.support import *
|
||||
|
||||
def cleanup_output_dir():
|
||||
output_dir = pathlib.Path(OUTPUT_DIR)
|
||||
if output_dir.exists():
|
||||
for f in output_dir.iterdir():
|
||||
f.unlink()
|
||||
else:
|
||||
output_dir.mkdir()
|
||||
|
||||
class TestDynamoFile(unittest.TestCase):
|
||||
|
||||
@@ -21,7 +13,7 @@ class TestDynamoFile(unittest.TestCase):
|
||||
# update_python_node
|
||||
# write
|
||||
|
||||
def test_read(self):
|
||||
def test_read_and_variables(self):
|
||||
dyn = dyn2py.DynamoFile(f"{INPUT_DIR}/python_nodes.dyn")
|
||||
dyn.read()
|
||||
|
||||
@@ -38,7 +30,7 @@ class TestDynamoFile(unittest.TestCase):
|
||||
dyn2.read()
|
||||
|
||||
|
||||
def test_get_python_node(self):
|
||||
def test_get_python_nodes(self):
|
||||
dyn = dyn2py.DynamoFile(f"{INPUT_DIR}/python_nodes.dyn")
|
||||
py_nodes = dyn.get_python_nodes()
|
||||
py_node = dyn.get_python_node_by_id("d7704617c75e4bf1a5c387b7c3f001ea")
|
||||
@@ -46,11 +38,19 @@ class TestDynamoFile(unittest.TestCase):
|
||||
self.assertEqual(len(py_nodes), 6)
|
||||
self.assertTrue(py_node)
|
||||
self.assertTrue(py_node in py_nodes)
|
||||
self.assertTrue(py_node in dyn.python_nodes)
|
||||
self.assertEqual(py_node.checksum, "1f3d9e6153804fe1ed37571a9cda8e26")
|
||||
|
||||
with self.assertRaises(dyn2py.PythonNodeNotFoundException):
|
||||
dyn.get_python_node_by_id("wrongid")
|
||||
|
||||
dyn2 = dyn2py.DynamoFile(f"{INPUT_DIR}/no_python.dyn")
|
||||
|
||||
# Raise error on file without python nodes:
|
||||
with self.assertRaises(dyn2py.DynamoFileException):
|
||||
dyn2.get_python_nodes()
|
||||
|
||||
|
||||
def test_extract_python(self):
|
||||
cleanup_output_dir()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user