Skip to content

Commit

Permalink
Merge pull request #8 from rocaz/feature/pr7
Browse files Browse the repository at this point in the history
feature/pr7
  • Loading branch information
rocaz authored Aug 28, 2021
2 parents accc64c + 7b6a496 commit 1928372
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 46 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.6, 3.7, 3.8]
python-version: [3.6, 3.7, 3.8, 3.9]

steps:
- uses: actions/checkout@v2
Expand All @@ -34,9 +34,9 @@ jobs:
pytest --cov=. -v -s --cov-report=xml
env:
GITHUBTOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
env_vars: OS,PYTHON
#- name: Upload coverage to Codecov
# uses: codecov/codecov-action@v1
# with:
# token: ${{ secrets.CODECOV_TOKEN }}
# file: ./coverage.xml
# env_vars: OS,PYTHON
2 changes: 1 addition & 1 deletion probeCOCOATek/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

from probeCOCOATek import TemporaryExposureKey

__version__ = '7.20200919'
__version__ = '8.20210828'
4 changes: 4 additions & 0 deletions probeCOCOATek/probeCOCOATek.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ def tek_toText(self, tek_bin:TemporaryExposureKeyExport) -> str:
text_lines.append(" [{:30}]:[{:}]".format("transmission_risk_level", str(k.transmission_risk_level)))
text_lines.append(" [{:30}]:[{:}]".format("rolling_start_interval_number", str(k.rolling_start_interval_number)))
text_lines.append(" [{:30}]:[{:}]".format("rolling_period", str(k.rolling_period)))
text_lines.append(" [{:30}]:[{:}]".format("report_type", str(k.report_type)))
text_lines.append(" [{:30}]:[{:}]".format("days_since_onset_of_symptoms", str(k.days_since_onset_of_symptoms)))
return text_lines


Expand All @@ -230,6 +232,8 @@ def tek_toJson(self, tek_bin:TemporaryExposureKeyExport) -> str:
kd["transmission_risk_level"] = k.transmission_risk_level
kd["rolling_start_interval_number"] = k.rolling_start_interval_number
kd["rolling_period"] = k.rolling_period
kd["report_type"] = k.report_type
kd["days_since_onset_of_symptoms"] = k.days_since_onset_of_symptoms
jd["keys"].append(kd)
return json.dumps(jd)

Expand Down
76 changes: 38 additions & 38 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'\
Expand All @@ -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'\
Expand All @@ -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'\
Expand Down
6 changes: 6 additions & 0 deletions tests/test_get_tek_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -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)
Expand All @@ -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)
Expand Down
Loading

0 comments on commit 1928372

Please sign in to comment.