Factor out duplicate code in executor repo tests
This simplifies some repeated code.
Change-Id: Ic733f54e6d9de13cfb02f1c48d6847adc0ae384c
diff --git a/tests/unit/test_executor.py b/tests/unit/test_executor.py
index 100e4ec..39b6070 100644
--- a/tests/unit/test_executor.py
+++ b/tests/unit/test_executor.py
@@ -61,6 +61,19 @@
'not have change %s' % (
project, build, number, change.subject))
+ def assertBuildStates(self, states, projects):
+ for number, build in enumerate(self.builds):
+ work = build.getWorkspaceRepos(projects)
+ state = states[number]
+
+ for project in projects:
+ self.assertRepoState(work[project], state[project],
+ project, build, number)
+
+ self.executor_server.hold_jobs_in_build = False
+ self.executor_server.release()
+ self.waitUntilSettled()
+
@simple_layout('layouts/repo-checkout-two-project.yaml')
def test_one_branch(self):
self.executor_server.hold_jobs_in_build = True
@@ -90,18 +103,7 @@
},
]
- for number, build in enumerate(self.builds):
- self.log.debug("Build parameters: %s", build.parameters)
- work = build.getWorkspaceRepos(projects)
- state = states[number]
-
- for project in projects:
- self.assertRepoState(work[project], state[project],
- project, build, number)
-
- self.executor_server.hold_jobs_in_build = False
- self.executor_server.release()
- self.waitUntilSettled()
+ self.assertBuildStates(states, projects)
@simple_layout('layouts/repo-checkout-four-project.yaml')
def test_multi_branch(self):
@@ -156,18 +158,7 @@
},
]
- for number, build in enumerate(self.builds):
- self.log.debug("Build parameters: %s", build.parameters)
- work = build.getWorkspaceRepos(projects)
- state = states[number]
-
- for project in projects:
- self.assertRepoState(work[project], state[project],
- project, build, number)
-
- self.executor_server.hold_jobs_in_build = False
- self.executor_server.release()
- self.waitUntilSettled()
+ self.assertBuildStates(states, projects)
@simple_layout('layouts/repo-checkout-six-project.yaml')
def test_project_override(self):
@@ -252,18 +243,7 @@
},
]
- for number, build in enumerate(self.builds):
- self.log.debug("Build parameters: %s", build.parameters)
- work = build.getWorkspaceRepos(projects)
- state = states[number]
-
- for project in projects:
- self.assertRepoState(work[project], state[project],
- project, build, number)
-
- self.executor_server.hold_jobs_in_build = False
- self.executor_server.release()
- self.waitUntilSettled()
+ self.assertBuildStates(states, projects)
def test_periodic(self):
# This test can not use simple_layout because it must start
@@ -300,18 +280,7 @@
},
]
- for number, build in enumerate(self.builds):
- self.log.debug("Build parameters: %s", build.parameters)
- work = build.getWorkspaceRepos(projects)
- state = states[number]
-
- for project in projects:
- self.assertRepoState(work[project], state[project],
- project, build, number)
-
- self.executor_server.hold_jobs_in_build = False
- self.executor_server.release()
- self.waitUntilSettled()
+ self.assertBuildStates(states, projects)
@simple_layout('layouts/repo-checkout-post.yaml')
def test_post_and_master_checkout(self):
@@ -335,15 +304,4 @@
},
]
- for number, build in enumerate(self.builds):
- self.log.debug("Build parameters: %s", build.parameters)
- work = build.getWorkspaceRepos(projects)
- state = states[number]
-
- for project in projects:
- self.assertRepoState(work[project], state[project],
- project, build, number)
-
- self.executor_server.hold_jobs_in_build = False
- self.executor_server.release()
- self.waitUntilSettled()
+ self.assertBuildStates(states, projects)