From 7b6a496142845acedd5cb963e7963a307757e521 Mon Sep 17 00:00:00 2001 From: rocaz Date: Sat, 28 Aug 2021 16:58:33 +0900 Subject: [PATCH] add assert for ENv2 fields --- tests/conftest.py | 76 +++++++++++++++++------------------ tests/test_get_tek_content.py | 6 +++ tests/test_tek_tojson.py | 2 + tests/test_tek_totext.py | 2 + 4 files changed, 48 insertions(+), 38 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 35e817f..ff4193f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -31,7 +31,7 @@ def zip_data(): 'verification_key_version':'v1','verification_key_id':'440','signature_algorithm':'1.2.840.10045.4.3.2', }, 'keys':[ - {'key_data':'40ea03a8cb3ad80df3b330b6493c69da','transmission_risk_level':0,'rolling_start_interval_number':2659248,'rolling_period':144} + {'key_data':'40ea03a8cb3ad80df3b330b6493c69da','transmission_risk_level':0,'rolling_start_interval_number':2659248,'rolling_period':144,'report_type':0, 'days_since_onset_of_symptoms':0} ], 'raw_data': '504b03041400000008000410f95020233547870000009b0000000a0000006578706f72742e62696e72f55670ad28c82f2a512833540002ce0615a978'\ @@ -50,11 +50,11 @@ def zip_data(): 'verification_key_version':'v1','verification_key_id':'440','signature_algorithm':'1.2.840.10045.4.3.2', }, 'keys':[ - {'key_data':'5ced4b2dec081fcea50a42255338eff5','transmission_risk_level':0,'rolling_start_interval_number':2660544,'rolling_period':144}, - {'key_data':'b38c0d52d91e3a943855629a8be913af','transmission_risk_level':0,'rolling_start_interval_number':2660544,'rolling_period':144}, - {'key_data':'5f6b493f4490910cb143e249eb32d2cb','transmission_risk_level':0,'rolling_start_interval_number':2660544,'rolling_period':144}, - {'key_data':'92cb692ae1359da107319ce5310b6add','transmission_risk_level':0,'rolling_start_interval_number':2660544,'rolling_period':144}, - {'key_data':'7be2506466fc8b95d843f382880be0d9','transmission_risk_level':0,'rolling_start_interval_number':2660544,'rolling_period':144} + {'key_data':'5ced4b2dec081fcea50a42255338eff5','transmission_risk_level':0,'rolling_start_interval_number':2660544,'rolling_period':144,'report_type':0, 'days_since_onset_of_symptoms':0}, + {'key_data':'b38c0d52d91e3a943855629a8be913af','transmission_risk_level':0,'rolling_start_interval_number':2660544,'rolling_period':144,'report_type':0, 'days_since_onset_of_symptoms':0}, + {'key_data':'5f6b493f4490910cb143e249eb32d2cb','transmission_risk_level':0,'rolling_start_interval_number':2660544,'rolling_period':144,'report_type':0, 'days_since_onset_of_symptoms':0}, + {'key_data':'92cb692ae1359da107319ce5310b6add','transmission_risk_level':0,'rolling_start_interval_number':2660544,'rolling_period':144,'report_type':0, 'days_since_onset_of_symptoms':0}, + {'key_data':'7be2506466fc8b95d843f382880be0d9','transmission_risk_level':0,'rolling_start_interval_number':2660544,'rolling_period':144,'report_type':0, 'days_since_onset_of_symptoms':0} ], 'raw_data': '504b030414000000080003780f51c342d271d4000000130100000a0000006578706f72742e62696e72f55670ad28c82f2a5128335400024e0626b578'\ @@ -74,38 +74,38 @@ def zip_data(): 'verification_key_version':'v1','verification_key_id':'440','signature_algorithm':'1.2.840.10045.4.3.2', }, 'keys':[ - {'key_data':'85ca24b815863adfa8555e4124e3421e','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144}, - {'key_data':'51af14515309f878d8d66897776ee012','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144}, - {'key_data':'c9f2a35c558e5e45c06abbbeab5bd657','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144}, - {'key_data':'722c706dc0c8dfa30691942e3bb4b2ca','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144}, - {'key_data':'bb98d27dd685131df8f1d173c78d8fe4','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144}, - {'key_data':'1b74130f39c3ac9a5a707646bdbdc6e3','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144}, - {'key_data':'4b79b4384b483c18a57e60b09415ab9a','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144}, - {'key_data':'fb72d04dbff16b81684578b0ba29326d','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144}, - {'key_data':'32fc05108893d671a13532becbfbb2a8','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144}, - {'key_data':'e13c1214971a381b2a42404ad3f84619','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144}, - {'key_data':'98e859e1af50e8cec820c63a9646a34d','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144}, - {'key_data':'256ce9e6f47870b083c42b45378153ff','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144}, - {'key_data':'2a5744b3e5d0e03926d02a68fd557989','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144}, - {'key_data':'03f3486f99e1943327fcda772bffc4c1','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144}, - {'key_data':'79ef78edbeeeaf3f2f7a591a72b15b70','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144}, - {'key_data':'730b19585edd0d61e7e5611aa81e062b','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144}, - {'key_data':'217d8b034354cd4e72c7f864e5d06241','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144}, - {'key_data':'e250f3c4aeaab88f0cdb9e35d330c564','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144}, - {'key_data':'ce462fed29dcbe3534e342766bf98e07','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144}, - {'key_data':'130a379c5642e9b007c5ec428450be70','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144}, - {'key_data':'2057e4ad10799ac4b8a3e1d615562c68','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144}, - {'key_data':'4b735e60f6a8f4fead475369d82a8e3e','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144}, - {'key_data':'1c879d376dd151d364648569c6ec9ee9','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144}, - {'key_data':'70c00386f07c7398b7eb1b5d8cde17fd','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144}, - {'key_data':'9b2a346f1e2bd2e12699625a58067349','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144}, - {'key_data':'57c85e9394e34fb41fa3f6cd6007e36f','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144}, - {'key_data':'68ab04d7187cffde41d4115992729bbb','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144}, - {'key_data':'c00f19f46381cb98799e99e9243cf056','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144}, - {'key_data':'ff53ed3d71a2c24ccfc8f323e1c023d0','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144}, - {'key_data':'81122959f8738766fcf89da1f5ec5242','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144}, - {'key_data':'95a063d51ab208934b687d91a3179bc5','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144}, - {'key_data':'fcdd23cbe642b5ea9a3555ca94d6ba45','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144}, + {'key_data':'85ca24b815863adfa8555e4124e3421e','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144,'report_type':0, 'days_since_onset_of_symptoms':0}, + {'key_data':'51af14515309f878d8d66897776ee012','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144,'report_type':0, 'days_since_onset_of_symptoms':0}, + {'key_data':'c9f2a35c558e5e45c06abbbeab5bd657','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144,'report_type':0, 'days_since_onset_of_symptoms':0}, + {'key_data':'722c706dc0c8dfa30691942e3bb4b2ca','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144,'report_type':0, 'days_since_onset_of_symptoms':0}, + {'key_data':'bb98d27dd685131df8f1d173c78d8fe4','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144,'report_type':0, 'days_since_onset_of_symptoms':0}, + {'key_data':'1b74130f39c3ac9a5a707646bdbdc6e3','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144,'report_type':0, 'days_since_onset_of_symptoms':0}, + {'key_data':'4b79b4384b483c18a57e60b09415ab9a','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144,'report_type':0, 'days_since_onset_of_symptoms':0}, + {'key_data':'fb72d04dbff16b81684578b0ba29326d','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144,'report_type':0, 'days_since_onset_of_symptoms':0}, + {'key_data':'32fc05108893d671a13532becbfbb2a8','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144,'report_type':0, 'days_since_onset_of_symptoms':0}, + {'key_data':'e13c1214971a381b2a42404ad3f84619','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144,'report_type':0, 'days_since_onset_of_symptoms':0}, + {'key_data':'98e859e1af50e8cec820c63a9646a34d','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144,'report_type':0, 'days_since_onset_of_symptoms':0}, + {'key_data':'256ce9e6f47870b083c42b45378153ff','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144,'report_type':0, 'days_since_onset_of_symptoms':0}, + {'key_data':'2a5744b3e5d0e03926d02a68fd557989','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144,'report_type':0, 'days_since_onset_of_symptoms':0}, + {'key_data':'03f3486f99e1943327fcda772bffc4c1','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144,'report_type':0, 'days_since_onset_of_symptoms':0}, + {'key_data':'79ef78edbeeeaf3f2f7a591a72b15b70','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144,'report_type':0, 'days_since_onset_of_symptoms':0}, + {'key_data':'730b19585edd0d61e7e5611aa81e062b','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144,'report_type':0, 'days_since_onset_of_symptoms':0}, + {'key_data':'217d8b034354cd4e72c7f864e5d06241','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144,'report_type':0, 'days_since_onset_of_symptoms':0}, + {'key_data':'e250f3c4aeaab88f0cdb9e35d330c564','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144,'report_type':0, 'days_since_onset_of_symptoms':0}, + {'key_data':'ce462fed29dcbe3534e342766bf98e07','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144,'report_type':0, 'days_since_onset_of_symptoms':0}, + {'key_data':'130a379c5642e9b007c5ec428450be70','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144,'report_type':0, 'days_since_onset_of_symptoms':0}, + {'key_data':'2057e4ad10799ac4b8a3e1d615562c68','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144,'report_type':0, 'days_since_onset_of_symptoms':0}, + {'key_data':'4b735e60f6a8f4fead475369d82a8e3e','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144,'report_type':0, 'days_since_onset_of_symptoms':0}, + {'key_data':'1c879d376dd151d364648569c6ec9ee9','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144,'report_type':0, 'days_since_onset_of_symptoms':0}, + {'key_data':'70c00386f07c7398b7eb1b5d8cde17fd','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144,'report_type':0, 'days_since_onset_of_symptoms':0}, + {'key_data':'9b2a346f1e2bd2e12699625a58067349','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144,'report_type':0, 'days_since_onset_of_symptoms':0}, + {'key_data':'57c85e9394e34fb41fa3f6cd6007e36f','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144,'report_type':0, 'days_since_onset_of_symptoms':0}, + {'key_data':'68ab04d7187cffde41d4115992729bbb','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144,'report_type':0, 'days_since_onset_of_symptoms':0}, + {'key_data':'c00f19f46381cb98799e99e9243cf056','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144,'report_type':0, 'days_since_onset_of_symptoms':0}, + {'key_data':'ff53ed3d71a2c24ccfc8f323e1c023d0','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144,'report_type':0, 'days_since_onset_of_symptoms':0}, + {'key_data':'81122959f8738766fcf89da1f5ec5242','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144,'report_type':0, 'days_since_onset_of_symptoms':0}, + {'key_data':'95a063d51ab208934b687d91a3179bc5','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144,'report_type':0, 'days_since_onset_of_symptoms':0}, + {'key_data':'fcdd23cbe642b5ea9a3555ca94d6ba45','transmission_risk_level':0,'rolling_start_interval_number':2662560,'rolling_period':144,'report_type':0, 'days_since_onset_of_symptoms':0}, ], 'raw_data': '504b03041400000008000c78115147709fb2d10200003d0400000a0000006578706f72742e62696e72f55670ad28c82f2a5128335400024e86728b78'\ diff --git a/tests/test_get_tek_content.py b/tests/test_get_tek_content.py index e75c95e..5a4bb54 100644 --- a/tests/test_get_tek_content.py +++ b/tests/test_get_tek_content.py @@ -39,6 +39,8 @@ def test_zip_from_url_nocache_normal(self, nocache, normal_distribution_url, zip assert set([k.transmission_risk_level for k in tek_bin.keys]) == set([z["transmission_risk_level"] for z in zip_data[url]["keys"]]) assert set([k.rolling_start_interval_number for k in tek_bin.keys]) == set([z["rolling_start_interval_number"] for z in zip_data[url]["keys"]]) assert set([k.rolling_period for k in tek_bin.keys]) == set([z["rolling_period"] for z in zip_data[url]["keys"]]) + assert set([k.report_type for k in tek_bin.keys]) == set([z["report_type"] for z in zip_data[url]["keys"]]) + assert set([k.days_since_onset_of_symptoms for k in tek_bin.keys]) == set([z["days_since_onset_of_symptoms"] for z in zip_data[url]["keys"]]) def test_zip_by_absfile_normal(self, normal_distribution_url, zip_data, tmpdir): for k,v in zip_data.items(): @@ -59,6 +61,8 @@ def test_zip_by_absfile_normal(self, normal_distribution_url, zip_data, tmpdir): assert set([k.transmission_risk_level for k in tek_bin.keys]) == set([z["transmission_risk_level"] for z in v1["keys"]]) assert set([k.rolling_start_interval_number for k in tek_bin.keys]) == set([z["rolling_start_interval_number"] for z in v1["keys"]]) assert set([k.rolling_period for k in tek_bin.keys]) == set([z["rolling_period"] for z in v1["keys"]]) + assert set([k.report_type for k in tek_bin.keys]) == set([z["report_type"] for z in v1["keys"]]) + assert set([k.days_since_onset_of_symptoms for k in tek_bin.keys]) == set([z["days_since_onset_of_symptoms"] for z in v1["keys"]]) def test_zip_by_relfile_withcache_normal(self, normal_distribution_url, zip_data): pCT = probeCOCOATek(normal_distribution_url) @@ -79,6 +83,8 @@ def test_zip_by_relfile_withcache_normal(self, normal_distribution_url, zip_data assert set([k.transmission_risk_level for k in tek_bin.keys]) == set([z["transmission_risk_level"] for z in v1["keys"]]) assert set([k.rolling_start_interval_number for k in tek_bin.keys]) == set([z["rolling_start_interval_number"] for z in v1["keys"]]) assert set([k.rolling_period for k in tek_bin.keys]) == set([z["rolling_period"] for z in v1["keys"]]) + assert set([k.report_type for k in tek_bin.keys]) == set([z["report_type"] for z in v1["keys"]]) + assert set([k.days_since_onset_of_symptoms for k in tek_bin.keys]) == set([z["days_since_onset_of_symptoms"] for z in v1["keys"]]) def test_zip_not_found_error(self, normal_distribution_url, zip_data): pCT = probeCOCOATek(normal_distribution_url) diff --git a/tests/test_tek_tojson.py b/tests/test_tek_tojson.py index bc1517a..f9e8704 100644 --- a/tests/test_tek_tojson.py +++ b/tests/test_tek_tojson.py @@ -45,6 +45,8 @@ def test_tekjson_normal(self, nocache, normal_distribution_url, normal_distribut assert k["transmission_risk_level"] in [tk.transmission_risk_level for tk in tek_bin.keys if k["key_data"] == tk.key_data.hex()] assert k["rolling_start_interval_number"] in [tk.rolling_start_interval_number for tk in tek_bin.keys if k["key_data"] == tk.key_data.hex()] assert k["rolling_period"] in [tk.rolling_period for tk in tek_bin.keys if k["key_data"] == tk.key_data.hex()] + assert k["report_type"] in [tk.report_type for tk in tek_bin.keys if k["key_data"] == tk.key_data.hex()] + assert k["days_since_onset_of_symptoms"] in [tk.days_since_onset_of_symptoms for tk in tek_bin.keys if k["key_data"] == tk.key_data.hex()] @pytest.mark.parametrize("nocache", [True, False]) diff --git a/tests/test_tek_totext.py b/tests/test_tek_totext.py index fe57cf1..e0dca1b 100644 --- a/tests/test_tek_totext.py +++ b/tests/test_tek_totext.py @@ -44,6 +44,8 @@ def test_tektext_normal(self, nocache, normal_distribution_url, normal_distribut assert True in [("transmission_risk_level" in l) and ("[{:}]".format(k.transmission_risk_level) in l) for l in text_lines] assert True in [("rolling_start_interval_number" in l) and ("[{:}]".format(k.rolling_start_interval_number) in l) for l in text_lines] assert True in [("rolling_period" in l) and ("[{:}]".format(k.rolling_period) in l) for l in text_lines] + assert True in [("report_type" in l) and ("[{:}]".format(k.report_type) in l) for l in text_lines] + assert True in [("days_since_onset_of_symptoms" in l) and ("[{:}]".format(k.days_since_onset_of_symptoms) in l) for l in text_lines] @pytest.mark.parametrize("nocache", [True, False]) def test_tektext_invalid_data_error(self, nocache, normal_distribution_url, normal_distribution_json, zip_data, invalid_zip_data):