|
8 | 8 |
|
9 | 9 |
|
10 | 10 | @pytest.mark.parametrize( |
11 | | - "task, expectation", |
| 11 | + "config, task, expectation, expected_result", |
12 | 12 | ( |
13 | | - pytest.param({"scopes": ["test:prefix:app:foo", "test:prefix:workflow:bar"]}, does_not_raise(), id="valid"), |
14 | | - pytest.param({"scopes": ["bad:prefix:app:foo", "test:prefix:workflow:bar"]}, pytest.raises(TaskVerificationError), id="invalid"), |
15 | | - pytest.param({"scopes": ["test:prefix:app:foo", "bad:prefix:workflow:bar"]}, pytest.raises(TaskVerificationError), id="invalid"), |
| 13 | + ( |
| 14 | + {"taskcluster_scope_prefixes": ["some:prefix"]}, |
| 15 | + {"scopes": ["some:prefix:project:someproject"]}, |
| 16 | + does_not_raise(), |
| 17 | + "some:prefix:", |
| 18 | + ), |
| 19 | + ( |
| 20 | + {"taskcluster_scope_prefixes": ["some:prefix:"]}, |
| 21 | + {"scopes": ["some:prefix:project:someproject"]}, |
| 22 | + does_not_raise(), |
| 23 | + "some:prefix:", |
| 24 | + ), |
| 25 | + ( |
| 26 | + {"taskcluster_scope_prefixes": ["some:prefix"]}, |
| 27 | + {"scopes": ["some:prefix:project:someproject", "some:prefix:action:someaction"]}, |
| 28 | + does_not_raise(), |
| 29 | + "some:prefix:", |
| 30 | + ), |
| 31 | + ( |
| 32 | + {"taskcluster_scope_prefixes": ["another:prefix"]}, |
| 33 | + {"scopes": ["some:prefix:project:someproject", "some:prefix:action:someaction"]}, |
| 34 | + pytest.raises(TaskVerificationError), |
| 35 | + None, |
| 36 | + ), |
| 37 | + ( |
| 38 | + {"taskcluster_scope_prefixes": ["some:prefix", "another:prefix"]}, |
| 39 | + {"scopes": ["some:prefix:project:someproject", "another:prefix:action:someaction"]}, |
| 40 | + pytest.raises(TaskVerificationError), |
| 41 | + None, |
| 42 | + ), |
16 | 43 | ), |
17 | 44 | ) |
18 | | -def test_validate_scope_prefixes(config, task, expectation): |
| 45 | +def test_extract_common_scope_prefix(config, task, expectation, expected_result): |
19 | 46 | with expectation: |
20 | | - task_mod.validate_scope_prefixes(config, task) |
| 47 | + assert task_mod.extract_common_scope_prefix(config, task) == expected_result |
21 | 48 |
|
22 | 49 |
|
23 | 50 | @pytest.mark.parametrize( |
@@ -65,20 +92,23 @@ def test_get_bitrise_app(config, task, expected): |
65 | 92 |
|
66 | 93 |
|
67 | 94 | @pytest.mark.parametrize( |
68 | | - "task, expected", |
| 95 | + "task, expectation, expected", |
69 | 96 | ( |
70 | 97 | ( |
71 | 98 | {"scopes": ["test:prefix:app:foo", "test:prefix:workflow:bar", "test:prefix:workflow:baz"]}, |
| 99 | + does_not_raise(), |
72 | 100 | ["bar", "baz"], |
73 | 101 | ), |
74 | 102 | ( |
75 | 103 | {"scopes": ["test:prefix:app:foo"]}, |
76 | | - [], |
| 104 | + pytest.raises(TaskVerificationError), |
| 105 | + None, |
77 | 106 | ), |
78 | 107 | ), |
79 | 108 | ) |
80 | | -def test_get_bitrise_workflows(config, task, expected): |
81 | | - assert task_mod.get_bitrise_workflows(config, task) == expected |
| 109 | +def test_get_bitrise_workflows(config, task, expectation, expected): |
| 110 | + with expectation: |
| 111 | + assert task_mod.get_bitrise_workflows(config, task) == expected |
82 | 112 |
|
83 | 113 |
|
84 | 114 | @pytest.mark.parametrize( |
|
0 commit comments