|
16 | 16 | # See the License for the specific language governing permissions and |
17 | 17 | # limitations under the License. |
18 | 18 | # ---license-end |
| 19 | +# |
| 20 | +# Dependencies: |
| 21 | +# Python 3.9 |
| 22 | +# pip install -r tests/requirements.txt |
| 23 | +# |
| 24 | +# Usage: |
| 25 | +# To run all tests: pytest |
| 26 | +# To run tests for a given country: pytest -C=<Country Code> . e.g. pytest -C=AT |
19 | 27 |
|
20 | 28 | import json |
21 | 29 | from base64 import b64decode |
22 | 30 | import base64 |
23 | | -from os import path |
| 31 | +import os |
24 | 32 | from pathlib import Path |
25 | 33 | from io import BytesIO |
26 | 34 | from json import load |
@@ -74,7 +82,7 @@ def pytest_generate_tests(metafunc): |
74 | 82 | if "config_env" in metafunc.fixturenames: |
75 | 83 | country_code = metafunc.config.getoption("country_code") |
76 | 84 | file_name = metafunc.config.getoption("file_name") |
77 | | - test_dir = path.dirname(path.dirname(path.abspath(__file__))) |
| 85 | + test_dir = os.dirname(os.path.dirname(os.path.abspath(__file__))) |
78 | 86 | test_files = glob( |
79 | 87 | str(Path(test_dir, country_code, "*", "*.png")), recursive=True) |
80 | 88 | metafunc.parametrize("config_env", test_files, indirect=True) |
@@ -263,8 +271,8 @@ def test_issuer_quality(config_env: Dict): |
263 | 271 |
|
264 | 272 | # If file path indicates JSON schema version, verify it against actual JSON schema version |
265 | 273 | # E.g. "<countrycode>/1.0.0/VAC.png" will trigger schema version verification, whereas "<countrycode>/1.0.0/exceptions/VAC.png" will not |
266 | | - if re.search("\\d\\.\\d\\.\\d", config_env[FILE_PATH].split("/")[-2]): |
267 | | - path_schema_version = config_env[FILE_PATH].split("/")[-2] |
| 274 | + if re.search("\\d\\.\\d\\.\\d", config_env[FILE_PATH].split(os.sep)[-2]): |
| 275 | + path_schema_version = config_env[FILE_PATH].split(os.sep)[-2] |
268 | 276 | dcc_schema_version = cose_payload[PAYLOAD_HCERT][PAYLOAD_ISSUER][VER] |
269 | 277 | if path_schema_version != dcc_schema_version: |
270 | 278 | fail("File path indicates {} but DCC contains {} JSON schema version".format( |
|
0 commit comments