From 7610646e10b4f725cb7e6a4466bbc24a2bffac1a Mon Sep 17 00:00:00 2001 From: Vladimir Date: Tue, 22 Feb 2022 09:50:11 +0100 Subject: [PATCH] Add FileReader test --- test/test_filereader.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 test/test_filereader.py diff --git a/test/test_filereader.py b/test/test_filereader.py new file mode 100644 index 0000000..857a111 --- /dev/null +++ b/test/test_filereader.py @@ -0,0 +1,21 @@ +import unittest +import tempfile + +from dsmr_parser.clients.filereader import FileReader +from dsmr_parser.telegram_specifications import V5 +from test.example_telegrams import TELEGRAM_V5 + + +class FileReaderTest(unittest.TestCase): + def test_read_as_object(self): + with tempfile.NamedTemporaryFile() as file: + with open(file.name, "w") as f: + f.write(TELEGRAM_V5) + + telegrams = [] + reader = FileReader(file=file.name, telegram_specification=V5) + # Call + for telegram in reader.read_as_object(): + telegrams.append(telegram) + + self.assertEqual(len(telegrams), 1)