""" AuDaGe XSY tests name: test_xsy.py by: Josh Lucas date: 2026-09-14 desc: Unit tests for the AuDaGe XSY module. """ import os import unittest from importlib import resources import output import assets from AuDaGe.formats.controlexpert.xsy import * ASSETS_PATH = "assets" OUTPUT_PATH = "output" class TestXSY(unittest.TestCase): """This test case tests the XSYBlock, DataBlock, and Definitions classes in the xsy module. """ def setUp(self): self.in_paths = [ file for file in resources.files(assets).iterdir() if os.path.splitext(file)[-1].lower() == ".xsy" ] def test_DataBlock(self): for in_path in self.in_paths: datablock = DataBlock.from_file(in_path) self.assertIsInstance(datablock, DataBlock) self.assertIsInstance(datablock, XSYBlock) def test_Definitions(self): for in_path in self.in_paths: definitions = Definitions.from_file(in_path) self.assertIsInstance(definitions, Definitions) self.assertIsInstance(definitions, XSYBlock) class TestXSYReader(unittest.TestCase): def setUp(self): self.xsy_reader = XSYReader() self.in_paths = [ file for file in resources.files(assets).iterdir() if os.path.splitext(file)[-1].lower() == ".xsy" ] self.out_path = resources.files(output) def test_init(self): self.assertIsInstance(self.xsy_reader, XSYReader) def test_read(self): for path in self.in_paths: xsy = self.xsy_reader.read(path) self.assertIsInstance(xsy, XSY) def test_export(self): for path in self.in_paths: file_name = os.path.splitext(os.path.split(path)[-1])[0] xsy = self.xsy_reader.read(path, expand=False) xsy.datablock.to_csv( self.out_path.joinpath(f"{file_name}_datablock.csv"), index=False ) xsy.definitions.to_csv( self.out_path.joinpath(f"{file_name}_definitions.csv"), index=False ) xsy.datablock.update(xsy.expand_datablock()) xsy.datablock.to_csv( self.out_path.joinpath(f"{file_name}_expanded.csv"), index=False ) if __name__ == "__main__": __package__ = "test_xsy" unittest.main(failfast=True)