Skip to content

Commit a555da8

Browse files
committed
base_wamas_ubl: fix html escaping & test freezetime
1 parent b3a3969 commit a555da8

File tree

6 files changed

+19
-1
lines changed

6 files changed

+19
-1
lines changed

base_wamas_ubl/lib/wamas/dict2wamas.py

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import logging
66
from ast import literal_eval
77
from pprint import pformat
8+
from freezegun import freeze_time
89

910
from . import const, utils
1011

@@ -60,6 +61,7 @@ def dict2wamas(dict_input, msg_type):
6061
return wamas
6162

6263

64+
@freeze_time("2024-02-11 22:14:22")
6365
def main():
6466
parser = argparse.ArgumentParser(
6567
description="Converts JSON document into message.",

base_wamas_ubl/lib/wamas/tests/test_dict2wamas.py

+7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
import ast
22
import unittest
33

4+
from freezegun import freeze_time
5+
46
from ..dict2wamas import dict2wamas
57
from ..utils import file_open, file_path
68

79

810
class TestDict2wamas(unittest.TestCase):
11+
12+
maxDiff = None
13+
914
def _test(self, msg_type, filename):
1015
with file_open(
1116
file_path("tests/samples/dict2wamas_input%s.dict" % filename)
@@ -17,9 +22,11 @@ def _test(self, msg_type, filename):
1722
expected_output = outfile.read()
1823
self.assertEqual(output, expected_output)
1924

25+
@freeze_time("2024-02-11 22:14:22")
2026
def test_LST(self):
2127
self._test("Supplier", "")
2228

29+
@freeze_time("2024-02-11 22:15:32")
2330
def test_KSTAUS(self):
2431
self._test("CustomerDeliveryPreferences", "_2")
2532

base_wamas_ubl/lib/wamas/tests/test_ubl2wamas.py

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55

66

77
class TestUbl2wamas(unittest.TestCase):
8+
9+
maxDiff = None
10+
811
def test_helpers(self):
912
dict_data = {
1013
"str": [

base_wamas_ubl/lib/wamas/tests/test_wamas2ubl.py

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99

1010

1111
class TestWamas2dict(unittest.TestCase):
12+
13+
maxDiff = None
14+
1215
def _test(self, filename):
1316
with file_open(
1417
file_path("tests/samples/%s.wamas" % filename)

base_wamas_ubl/lib/wamas/tests/test_wamas2wamas.py

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88

99
class TestWamas2wamas(unittest.TestCase):
10+
11+
maxDiff = None
12+
1013
def _test(self, filename):
1114
with file_open(
1215
file_path("tests/samples/wamas2wamas_input_%s.wamas" % filename)

base_wamas_ubl/lib/wamas/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ def fw2dict(line, grammar, telegram_type):
408408
dp = fdef["dp"]
409409
val = float(b[:-dp] + "." + b[-dp:])
410410
else:
411-
val = escape(b.rstrip())
411+
val = str(escape(b.rstrip()))
412412
res[fname] = val
413413
_logger.debug(pformat(res))
414414
return res

0 commit comments

Comments
 (0)