Implement tests.
This commit is contained in:
0
tests/__init__.py
Normal file
0
tests/__init__.py
Normal file
23
tests/test_audage.py
Normal file
23
tests/test_audage.py
Normal file
@@ -0,0 +1,23 @@
|
||||
import unittest
|
||||
|
||||
from AuDaGe.audage import AuDaGeFrame
|
||||
|
||||
class TestAuDaGeFrame(unittest.TestCase):
|
||||
def test_init(self):
|
||||
valid_adf = AuDaGeFrame({
|
||||
"name": ["a", "b", "c"],
|
||||
"type": ["d", "e", "f"],
|
||||
"address": [1, 2, 3],
|
||||
"comment": ["g", "h", "i"]
|
||||
})
|
||||
self.assertTrue(valid_adf.is_valid())
|
||||
invalid_adf = AuDaGeFrame({
|
||||
"name": ["a", "b", "c"],
|
||||
# "type": ["d", "e", "f"],
|
||||
"address": [1, 2, 3],
|
||||
"comment": ["g", "h", "i"]
|
||||
})
|
||||
self.assertFalse(invalid_adf.is_valid())
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main(failfast=True)
|
||||
11
tests/test_format.py
Normal file
11
tests/test_format.py
Normal file
@@ -0,0 +1,11 @@
|
||||
"""
|
||||
AuDaGe format tests
|
||||
|
||||
name: test_format.py
|
||||
by: Josh Lucas
|
||||
date: 2026-09-14
|
||||
|
||||
desc: Unit tests for the AuDaGe format module.
|
||||
"""
|
||||
|
||||
import unittest
|
||||
27
tests/test_iec.py
Normal file
27
tests/test_iec.py
Normal file
@@ -0,0 +1,27 @@
|
||||
"""
|
||||
AuDaGe IEC tests
|
||||
|
||||
name: test_iec.py
|
||||
by: Josh Lucas
|
||||
date: 2026-09-14
|
||||
|
||||
desc: Unit tests for the AuDaGe IEC module.
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
from AuDaGe import iec
|
||||
|
||||
class TestIEC(unittest.TestCase):
|
||||
""""""
|
||||
|
||||
def test_iec_definitions(self):
|
||||
iec_definitions = iec.iec_definitions()
|
||||
self.assertTrue(iec_definitions.is_valid())
|
||||
self.assertEqual(
|
||||
iec_definitions.shape,
|
||||
(len(iec.DataTypes.__members__), 7)
|
||||
)
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main(failfast=True)
|
||||
@@ -1,26 +1,45 @@
|
||||
import os
|
||||
"""
|
||||
AuDaGe XSY tests
|
||||
|
||||
from pandas import DataFrame
|
||||
name: test_xsy.py
|
||||
by: Josh Lucas
|
||||
date: 2026-09-14
|
||||
|
||||
desc: Unit tests for the AuDaGe XSY module.
|
||||
"""
|
||||
|
||||
import os
|
||||
import unittest
|
||||
from timeit import default_timer as timer
|
||||
|
||||
# from pandas import DataFrame
|
||||
|
||||
from AuDaGe.formats.controlexpert.xsy import XSY
|
||||
|
||||
def test_init():
|
||||
assert isinstance(XSY("tests/data/hsps.xsy"), XSY)
|
||||
IN_PATH = "tests/assets"
|
||||
OUT_PATH = "tests/output"
|
||||
|
||||
def test_export():
|
||||
xsy = XSY()
|
||||
datablock = xsy.read("tests/data/hsps.xsy", expand=False)
|
||||
print(xsy.def_paths)
|
||||
out_path = "tests/output"
|
||||
datablock.to_csv(
|
||||
os.path.join(out_path, "datablock.csv"),
|
||||
index=False
|
||||
)
|
||||
xsy.defs.to_csv(
|
||||
os.path.join(out_path, "defs.csv"),
|
||||
index=False
|
||||
)
|
||||
xsy.expand_datablock(datablock).to_csv(
|
||||
os.path.join(out_path, "expanded.csv"),
|
||||
index=False
|
||||
)
|
||||
class TestXSY(unittest.TestCase):
|
||||
|
||||
def test_init(self):
|
||||
assert isinstance(XSY(os.path.join(IN_PATH, "hsps.xsy")), XSY)
|
||||
|
||||
def test_export(self):
|
||||
xsy = XSY()
|
||||
xsy.read(os.path.join(IN_PATH, "hsps.xsy"), expand=False)
|
||||
xsy.datablock.to_csv(
|
||||
os.path.join(OUT_PATH, "datablock.csv"),
|
||||
index=False
|
||||
)
|
||||
xsy.definitions.to_csv(
|
||||
os.path.join(OUT_PATH, "defs.csv"),
|
||||
index=False
|
||||
)
|
||||
# xsy.expand_datablock(datablock).to_csv(
|
||||
# os.path.join(OUT_PATH, "expanded.csv"),
|
||||
# index=False
|
||||
# )
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main(failfast=True)
|
||||
Reference in New Issue
Block a user