Gregory Haynes | 4fc1254 | 2015-04-22 20:38:06 -0700 | [diff] [blame] | 1 | # Copyright 2015 GoodData |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 4 | # not use this file except in compliance with the License. You may obtain |
| 5 | # a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 12 | # License for the specific language governing permissions and limitations |
| 13 | # under the License. |
| 14 | |
| 15 | import logging |
| 16 | |
| 17 | from tests.base import ZuulTestCase, simple_layout |
| 18 | |
| 19 | logging.basicConfig(level=logging.DEBUG, |
| 20 | format='%(asctime)s %(name)-32s ' |
| 21 | '%(levelname)-8s %(message)s') |
| 22 | |
| 23 | |
| 24 | class TestGithubDriver(ZuulTestCase): |
| 25 | config_file = 'zuul-github-driver.conf' |
| 26 | |
| 27 | @simple_layout('layouts/basic-github.yaml', driver='github') |
| 28 | def test_pull_event(self): |
| 29 | self.executor_server.hold_jobs_in_build = True |
| 30 | |
| 31 | pr = self.fake_github.openFakePullRequest('org/project', 'master') |
| 32 | self.fake_github.emitEvent(pr.getPullRequestOpenedEvent()) |
| 33 | self.waitUntilSettled() |
| 34 | |
| 35 | build_params = self.builds[0].parameters |
| 36 | self.assertEqual('master', build_params['ZUUL_BRANCH']) |
| 37 | self.assertEqual(str(pr.number), build_params['ZUUL_CHANGE']) |
| 38 | self.assertEqual(pr.head_sha, build_params['ZUUL_PATCHSET']) |
| 39 | |
| 40 | self.executor_server.hold_jobs_in_build = False |
| 41 | self.executor_server.release() |
| 42 | self.waitUntilSettled() |
| 43 | |
| 44 | self.assertEqual('SUCCESS', |
| 45 | self.getJobFromHistory('project-test1').result) |
| 46 | self.assertEqual('SUCCESS', |
| 47 | self.getJobFromHistory('project-test2').result) |
| 48 | |
| 49 | job = self.getJobFromHistory('project-test2') |
| 50 | zuulvars = job.parameters['vars']['zuul'] |
| 51 | self.assertEqual(pr.number, zuulvars['change']) |
| 52 | self.assertEqual(pr.head_sha, zuulvars['patchset']) |
Wayne | 40f4004 | 2015-06-12 16:56:30 -0700 | [diff] [blame^] | 53 | self.assertEqual(1, len(pr.comments)) |