|
6 | 6 | from copy import deepcopy |
7 | 7 | from pprint import pprint |
8 | 8 |
|
| 9 | +import pytest |
9 | 10 | from pytest_taskgraph import FakeParameters |
10 | 11 |
|
11 | 12 | from taskgraph.transforms import task_context |
|
14 | 15 | here = os.path.abspath(os.path.dirname(__file__)) |
15 | 16 |
|
16 | 17 | TASK_DEFAULTS = { |
17 | | - "description": "fake description {object} {file} {param} {object_and_file}" |
| 18 | + "description": "fake description {object} {file} {param} {object_and_file} " |
18 | 19 | "{object_and_param} {file_and_param} {object_file_and_param} {param_fallback} {name}", |
19 | 20 | "name": "fake-task-name", |
20 | 21 | "task-context": { |
|
37 | 38 | ], |
38 | 39 | }, |
39 | 40 | } |
| 41 | +EXPECTED_DESCRIPTION = ( |
| 42 | + "fake description object file param object-overrides-file " |
| 43 | + "param-overrides-object param-overrides-file param-overrides-all default fake-task-name" |
| 44 | +) |
| 45 | +NO_CONTEXT = deepcopy(TASK_DEFAULTS) |
| 46 | +del NO_CONTEXT["task-context"] |
40 | 47 |
|
41 | 48 |
|
42 | | -def test_transforms(request, run_transform, graph_config): |
43 | | - task = deepcopy(TASK_DEFAULTS) |
44 | | - |
| 49 | +@pytest.mark.parametrize( |
| 50 | + "task,description", |
| 51 | + ( |
| 52 | + pytest.param(deepcopy(TASK_DEFAULTS), EXPECTED_DESCRIPTION, id="with-context"), |
| 53 | + pytest.param( |
| 54 | + deepcopy(NO_CONTEXT), TASK_DEFAULTS["description"], id="no-context" |
| 55 | + ), |
| 56 | + ), |
| 57 | +) |
| 58 | +def test_transforms(request, run_transform, graph_config, task, description): |
45 | 59 | params = FakeParameters( |
46 | 60 | { |
47 | 61 | "param": "param", |
@@ -77,8 +91,4 @@ def test_transforms(request, run_transform, graph_config): |
77 | 91 | print("Dumping task:") |
78 | 92 | pprint(task, indent=2) |
79 | 93 |
|
80 | | - assert ( |
81 | | - task["description"] |
82 | | - == "fake description object file param object-overrides-file" |
83 | | - "param-overrides-object param-overrides-file param-overrides-all default fake-task-name" |
84 | | - ) |
| 94 | + assert task["description"] == description |
0 commit comments