|
5 | 5 | import pytest |
6 | 6 |
|
7 | 7 |
|
8 | | -def test_archive_does_not_open_on_signature_resource_or_schemas_missing(): |
| 8 | +@pytest.mark.parametrize("case", [ |
| 9 | + "missing_signature", |
| 10 | + "corrupt_signature", |
| 11 | + "missing_schema", |
| 12 | + "corrupt_schema", |
| 13 | + "missing_resource", |
| 14 | + "missing_resource_schema", |
| 15 | + "corrupt_resource_schema" |
| 16 | +]) |
| 17 | +def test_archive_does_not_open_on_signature_resource_or_schemas_missing(case): |
9 | 18 | module = Engine(INSTANCE_TEST_SCHEMA).render_python_module() |
10 | 19 | valid_data = { |
11 | 20 | "Archive.archive": ARCHIVE_SIGNATURE_PAYLOAD, |
@@ -38,21 +47,19 @@ def test_archive_does_not_open_on_signature_resource_or_schemas_missing(): |
38 | 47 | corrupt_resource_schema = valid_data.copy() |
39 | 48 | corrupt_resource_schema["resource.schema"] = b"foo" |
40 | 49 |
|
41 | | - datasets = [ |
42 | | - (missing_signature, CorruptArchiveError), |
43 | | - (corrupt_signature, CorruptArchiveError), |
44 | | - (missing_schema, CorruptArchiveError), |
45 | | - (corrupt_schema, SchemaMismatchError), |
46 | | - (missing_resource, CorruptArchiveError), |
47 | | - (missing_resource_schema, CorruptArchiveError), |
48 | | - (corrupt_resource_schema, SchemaMismatchError), |
49 | | - ] |
50 | | - |
51 | | - def _test(index, data, error_type): |
| 50 | + datasets = { |
| 51 | + "missing_signature": (missing_signature, CorruptArchiveError), |
| 52 | + "corrupt_signature": (corrupt_signature, CorruptArchiveError), |
| 53 | + "missing_schema": (missing_schema, CorruptArchiveError), |
| 54 | + "corrupt_schema": (corrupt_schema, SchemaMismatchError), |
| 55 | + "missing_resource": (missing_resource, CorruptArchiveError), |
| 56 | + "missing_resource_schema": (missing_resource_schema, CorruptArchiveError), |
| 57 | + "corrupt_resource_schema": (corrupt_resource_schema, SchemaMismatchError), |
| 58 | + } |
| 59 | + |
| 60 | + def _test(data, error_type): |
52 | 61 | with pytest.raises(error_type): |
53 | 62 | module.backward_compatibility_Archive(DictResourceStorage(data)) |
54 | 63 |
|
55 | | - for index, payload in enumerate(datasets): |
56 | | - data, error_type = payload |
57 | | - |
58 | | - _test(index, data, error_type) |
| 64 | + data, error_type = datasets[case] |
| 65 | + _test(data, error_type) |
0 commit comments