Add Kepserver CSV processing functionality.
This commit is contained in:
20000
tests/assets/WA3251_PLC_001_1.csv
Normal file
20000
tests/assets/WA3251_PLC_001_1.csv
Normal file
File diff suppressed because it is too large
Load Diff
70
tests/test_kepserver.py
Normal file
70
tests/test_kepserver.py
Normal file
@@ -0,0 +1,70 @@
|
||||
"""
|
||||
AuDaGe Kepserver tests
|
||||
|
||||
name: test_kepserver.py
|
||||
by: Josh Lucas
|
||||
date: 2026-10-13
|
||||
|
||||
desc: Unit tests for the AuDaGe kepserver.csv module.
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from importlib import resources
|
||||
|
||||
from AuDaGe.debug_tools import MeasureTime
|
||||
from AuDaGe.formats.kepserver import csv
|
||||
from AuDaGe.frame import AuDaGeFrame
|
||||
|
||||
try:
|
||||
from tests import assets, output
|
||||
except ImportError: # pragma: no cover
|
||||
import assets # noqa: I001
|
||||
import output
|
||||
|
||||
|
||||
class TestCSV(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.input_file = resources.files(assets).joinpath(
|
||||
"WA3251_PLC_001_1.csv"
|
||||
)
|
||||
self.output_folder = resources.files(output)
|
||||
with MeasureTime(
|
||||
do_print=True,
|
||||
message="Kepserver CSV import completed in {time:.3f} {unit}",
|
||||
):
|
||||
self.csv_frame = csv.Frame.from_file(self.input_file)
|
||||
with MeasureTime(
|
||||
do_print=True,
|
||||
message=(
|
||||
"Kepserver CSV frame translation to AuDaGeFrame completed in "
|
||||
"{time:.3f} {unit}"
|
||||
),
|
||||
):
|
||||
self.af = self.csv_frame.to_AF()
|
||||
|
||||
def test_read(self):
|
||||
self.assertIsInstance(self.csv_frame, csv.Frame)
|
||||
|
||||
def test_from_af(self):
|
||||
with MeasureTime(
|
||||
do_print=True,
|
||||
message=(
|
||||
"Kepserver CSV frame translation from AuDaGeFrame completed in "
|
||||
"{time:.3f} {unit}"
|
||||
),
|
||||
):
|
||||
translate_from_af = csv.Frame.from_AF(self.af)
|
||||
self.assertIsInstance(translate_from_af, csv.Frame)
|
||||
translate_from_af.to_file(
|
||||
self.output_folder.joinpath("kep_from_af.csv")
|
||||
)
|
||||
|
||||
def test_to_af(self):
|
||||
self.assertIsInstance(self.af, AuDaGeFrame)
|
||||
|
||||
def test_write(self):
|
||||
self.csv_frame.to_file(self.output_folder.joinpath("kepserver.csv"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main(failfast=True)
|
||||
Reference in New Issue
Block a user