Skip to content

Add find_action and find_all_actions methods for Pipeline class to reduce unit test boilerplate code

Igor Ponomarev requested to merge add-pipeline-find-action into master

Those methods can be used in the unit tests to replace the following constructs.

overlay = [
    action
    for action in self.job.pipeline.actions
    if action.name == "scp-overlay"
][0] # Repeats 2-4 times

The methods take an Action class and go through the job pipelines to find the object of a given class.

find_action returns on the first matching action.

find_all_actions returns a list of all matching actions.

These methods also have an advantage that code analysis tools will now show where the Action is being tested inside the unit tests.

The git stats shows 596 insertions(+) and 1923 deletions(-) meaning those methods managed to remove 1327 lines of boilerplate code.

Merge request reports