76
75
def test_build_job(self):
77
76
jenkins_cxt = patch('schedule_reliability_tests.Jenkins')
78
77
with jenkins_cxt as jenkins_mock, temp_dir() as root:
79
write_config(root, 'foo', 'quxxx')
80
78
build_job(Credentials('jrandom', 'password1'), root, 'foo',
81
79
[('bar', 1), ('baz', 2)], ['qux'])
82
80
jenkins_mock.assert_called_once_with(
83
'http://localhost:8080', 'jrandom', 'password1')
81
'http://juju-ci.vapour.ws:8080', 'jrandom', 'password1')
84
82
calls = jenkins_mock.return_value.build_job.mock_calls
89
'new_juju_dir': 'bar',
90
87
'revision_build': '1',
95
'new_juju_dir': 'baz',
96
92
'revision_build': '2'
99
95
self.assertEqual(calls, expected)
101
97
def test_build_job_multi_suite(self):
102
98
jenkins_cxt = patch('schedule_reliability_tests.Jenkins')
103
99
with jenkins_cxt as jenkins_mock, temp_dir() as root:
104
write_config(root, 'foo', 'bar')
105
100
build_job(Credentials('jrandom', 'password1'), root, 'foo',
106
101
[('baz', 1)], ['qux', 'quxx'])
107
102
jenkins_mock.return_value.build_job.assert_called_once_with(
109
104
'suite': 'qux,quxx',
110
105
'attempts': '10',
111
'new_juju_dir': 'baz',
112
106
'revision_build': '1',
116
110
class TestMain(TestCase):
129
122
def test_selects_newest_candidate(self):
130
123
with self.build_job_context() as root:
131
path_1234 = make_candidate_dir(
132
root, '1234', 'mybranch', '1234')
124
make_candidate_dir(root, '1234-artifacts', 'mybranch', '1234')
133
125
make_candidate_dir(root, '1233', 'mybranch', '1233')
134
126
build_job_mock = self.run_main(root)
135
127
build_job_mock.assert_called_once_with('foo', {
136
'new_juju_dir': path_1234,
137
128
'attempts': '10',
139
130
'revision_build': '1234',
142
133
def test_limit_3(self):
143
134
# Even though it's only testing the latest, it should only test 3,
144
135
# even if there are more than 3 latest.
145
136
with self.build_job_context() as root:
146
137
make_candidate_dir(
147
root, 'branch1', 'mybranch1')
149
root, 'branch2', 'mybranch2')
151
root, 'branch3', 'mybranch3')
153
root, 'branch4', 'mybranch4')
138
root, 'branch1-artifacts', 'mybranch1')
140
root, 'branch2-artifacts', 'mybranch2')
142
root, 'branch3-artifacts', 'mybranch3')
144
root, 'branch4-artifacts', 'mybranch4')
154
145
build_job_mock = self.run_main(root)
155
146
self.assertEqual(build_job_mock.call_count, 3)