Add config-based database conversion.
This commit is contained in:
@@ -19,20 +19,27 @@ try:
|
||||
from tests import assets, output
|
||||
except ImportError: # pragma: no cover
|
||||
import assets # noqa: I001
|
||||
import output
|
||||
import output # ty: ignore[unresolved-import]
|
||||
|
||||
INPUT_FILES = (
|
||||
"RTU_Status_List.csv",
|
||||
"WA3251_PLC_001_1.csv",
|
||||
)
|
||||
|
||||
|
||||
class TestCSV(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.input_file = resources.files(assets).joinpath(
|
||||
"WA3251_PLC_001_1.csv"
|
||||
self.input_files = (
|
||||
resources.files(assets).joinpath(file) for file in INPUT_FILES
|
||||
)
|
||||
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)
|
||||
self.csv_frames = (
|
||||
csv.Frame.from_file(file) for file in self.input_files
|
||||
)
|
||||
with MeasureTime(
|
||||
do_print=True,
|
||||
message=(
|
||||
@@ -40,30 +47,34 @@ class TestCSV(unittest.TestCase):
|
||||
"{time:.3f} {unit}"
|
||||
),
|
||||
):
|
||||
self.af = self.csv_frame.to_AF()
|
||||
self.afs = (frame.to_AF() for frame in self.csv_frames)
|
||||
|
||||
def test_read(self):
|
||||
self.assertIsInstance(self.csv_frame, csv.Frame)
|
||||
for frame in self.csv_frames:
|
||||
self.assertIsInstance(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")
|
||||
)
|
||||
for i, frame in enumerate(self.afs):
|
||||
with MeasureTime(
|
||||
do_print=True,
|
||||
message=(
|
||||
"Kepserver CSV frame translation from AuDaGeFrame "
|
||||
"completed in {time:.3f} {unit}"
|
||||
),
|
||||
):
|
||||
translate_from_af = csv.Frame.from_AF(frame)
|
||||
self.assertIsInstance(translate_from_af, csv.Frame)
|
||||
translate_from_af.to_file(
|
||||
self.output_folder.joinpath("kep_from_af{i}.csv")
|
||||
)
|
||||
|
||||
def test_to_af(self):
|
||||
self.assertIsInstance(self.af, AuDaGeFrame)
|
||||
for frame in self.afs:
|
||||
self.assertIsInstance(frame, AuDaGeFrame)
|
||||
|
||||
def test_write(self):
|
||||
self.csv_frame.to_file(self.output_folder.joinpath("kepserver.csv"))
|
||||
for i, frame in enumerate(self.csv_frames):
|
||||
frame.to_file(self.output_folder.joinpath(f"kepserver{i}.csv"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user