-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconftest.py
45 lines (36 loc) · 1.27 KB
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import pytest
from myjenkins.testing import jenkins_mocks
from myjenkins.log import setup_logging
def pytest_configure():
setup_logging(2)
@pytest.fixture
def client():
"""Fixture. Returns a Jenkins client which exposes a job which has
builds and subbuilds."""
# create three jobs
top_level_job = jenkins_mocks.create_job('top')
sub_job_1 = jenkins_mocks.create_job('sub_1')
sub_job_2 = jenkins_mocks.create_job('sub_2')
# each having one build
top_level_build = jenkins_mocks.create_build(1)
sub_job_1_build = jenkins_mocks.create_build(1)
sub_job_2_build = jenkins_mocks.create_build(1)
# pretend that the build for the top level job triggered the sub jobs
top_level_build._data = {
'subBuilds': [
{'jobName': 'sub_1', 'buildNumber': 1},
{'jobName': 'sub_2', 'buildNumber': 1},
]
}
# associate each job which its respective builds
top_level_job._builds = {1: top_level_build}
sub_job_1._builds = {1: sub_job_1_build}
sub_job_2._builds = {1: sub_job_2_build}
# create a client which contains those jobs
client = jenkins_mocks.create_client()
client._jobs = {
'top': top_level_job,
'sub_1': sub_job_1,
'sub_2': sub_job_2,
}
return client