|
34 | 34 |
|
35 | 35 | from powerapi.cli.binding_manager import PreProcessorBindingManager |
36 | 36 | from powerapi.dispatcher import DispatcherActor |
37 | | -from powerapi.exception import UnsupportedActorTypeException, UnexistingActorException, \ |
38 | | - TargetActorAlreadyUsed |
| 37 | +from powerapi.exception import UnsupportedActorTypeException, UnexistingActorException, TargetActorAlreadyUsed |
39 | 38 | from powerapi.processor.processor_actor import ProcessorActor |
40 | 39 |
|
41 | 40 |
|
@@ -134,35 +133,36 @@ def test_check_processors_targets_are_unique_pass_without_reused_puller_in_bindi |
134 | 133 | pytest.fail("Processors targets are not unique") |
135 | 134 |
|
136 | 135 |
|
137 | | -def test_check_processor_targets_raise_exception_with_no_existing_puller( |
138 | | - pre_processor_binding_manager_with_unexisting_puller): |
| 136 | +def check_all_processors_targets(preprocessor_binding_manager: PreProcessorBindingManager): |
| 137 | + """ |
| 138 | + Helper function that checks the processors targets of the given binding manager. |
| 139 | + """ |
| 140 | + for processor in preprocessor_binding_manager.processors.values(): |
| 141 | + preprocessor_binding_manager.check_processor_targets(processor) |
| 142 | + |
| 143 | + |
| 144 | +def test_check_processor_targets_raise_exception_with_no_existing_puller(pre_processor_binding_manager_with_unexisting_puller): |
139 | 145 | """ |
140 | 146 | Test that an exception is raised with a puller that doesn't exist |
141 | 147 | """ |
142 | | - pre_processor_binding_manager = pre_processor_binding_manager_with_unexisting_puller |
143 | 148 | with pytest.raises(UnexistingActorException): |
144 | | - for _, processor in pre_processor_binding_manager.processors.items(): |
145 | | - pre_processor_binding_manager.check_processor_targets(processor=processor) |
| 149 | + check_all_processors_targets(pre_processor_binding_manager_with_unexisting_puller) |
146 | 150 |
|
147 | 151 |
|
148 | | -def test_check_processor_targets_raise_exception_with_raise_exception_with_wrong_binding_types( |
149 | | - pre_processor_binding_manager_with_wrong_binding_types): |
| 152 | +def test_check_processor_targets_raise_exception_with_raise_exception_with_wrong_binding_types(pre_processor_binding_manager_with_wrong_binding_types): |
150 | 153 | """ |
151 | 154 | Test that an exception is raised with a puller that doesn't exist |
152 | 155 | """ |
153 | | - pre_processor_binding_manager = pre_processor_binding_manager_with_wrong_binding_types |
154 | 156 | with pytest.raises(UnsupportedActorTypeException): |
155 | | - for _, processor in pre_processor_binding_manager.processors.items(): |
156 | | - pre_processor_binding_manager.check_processor_targets(processor=processor) |
| 157 | + check_all_processors_targets(pre_processor_binding_manager_with_wrong_binding_types) |
157 | 158 |
|
158 | 159 |
|
159 | 160 | def test_check_processor_targets_pass_with_correct_targets(pre_processor_binding_manager): |
160 | 161 | """ |
161 | 162 | Test that validation of a configuration with existing targets of the correct type |
162 | 163 | """ |
163 | 164 | try: |
164 | | - for _, processor in pre_processor_binding_manager.processors.items(): |
165 | | - pre_processor_binding_manager.check_processor_targets(processor=processor) |
| 165 | + check_all_processors_targets(pre_processor_binding_manager) |
166 | 166 | except UnsupportedActorTypeException as e: |
167 | 167 | pytest.fail(f'Unsupported actor type: {e}') |
168 | 168 | except UnexistingActorException as e: |
|
0 commit comments