From f7e64b2d389c12a73b7b43745ba20d40130dec46 Mon Sep 17 00:00:00 2001 From: Fabian Joswig Date: Fri, 10 Dec 2021 10:43:52 +0000 Subject: [PATCH] test: json io test extended --- tests/io_test.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/tests/io_test.py b/tests/io_test.py index 18a48a76..a14ed52d 100644 --- a/tests/io_test.py +++ b/tests/io_test.py @@ -1,7 +1,8 @@ +import os +import gzip +import numpy as np import pyerrors as pe import pyerrors.input.json as jsonio -import numpy as np -import os def test_jsonio(): @@ -70,6 +71,15 @@ def test_jsonio(): def test_json_string_reconstruction(): my_obs = pe.Obs([np.random.rand(100)], ['name']) + json_string = pe.input.json.create_json_string(my_obs) - reconstructed_obs = pe.input.json.import_json_string(json_string) - assert my_obs == reconstructed_obs + reconstructed_obs1 = pe.input.json.import_json_string(json_string) + assert my_obs == reconstructed_obs1 + + compressed_string = gzip.compress(json_string.encode('utf-8')) + + reconstructed_string = gzip.decompress(compressed_string).decode('utf-8') + reconstructed_obs2 = pe.input.json.import_json_string(reconstructed_string) + + assert reconstructed_string == json_string + assert my_obs == reconstructed_obs2