Support GitHub PR webhooks

Story: 2000774

Change-Id: I2713c5d19326213539689e9d822831a393b2bf19
Co-Authored-By: Wayne Warren <waynr+launchpad@sdf.org>
Co-Authored-By: Jan Hruban <jan.hruban@gooddata.com>
Co-Authored-By: Jesse Keating <omgjlk@us.ibm.com>
diff --git a/tests/unit/test_github_driver.py b/tests/unit/test_github_driver.py
new file mode 100644
index 0000000..58f456f
--- /dev/null
+++ b/tests/unit/test_github_driver.py
@@ -0,0 +1,52 @@
+# Copyright 2015 GoodData
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import logging
+
+from tests.base import ZuulTestCase, simple_layout
+
+logging.basicConfig(level=logging.DEBUG,
+                    format='%(asctime)s %(name)-32s '
+                    '%(levelname)-8s %(message)s')
+
+
+class TestGithubDriver(ZuulTestCase):
+    config_file = 'zuul-github-driver.conf'
+
+    @simple_layout('layouts/basic-github.yaml', driver='github')
+    def test_pull_event(self):
+        self.executor_server.hold_jobs_in_build = True
+
+        pr = self.fake_github.openFakePullRequest('org/project', 'master')
+        self.fake_github.emitEvent(pr.getPullRequestOpenedEvent())
+        self.waitUntilSettled()
+
+        build_params = self.builds[0].parameters
+        self.assertEqual('master', build_params['ZUUL_BRANCH'])
+        self.assertEqual(str(pr.number), build_params['ZUUL_CHANGE'])
+        self.assertEqual(pr.head_sha, build_params['ZUUL_PATCHSET'])
+
+        self.executor_server.hold_jobs_in_build = False
+        self.executor_server.release()
+        self.waitUntilSettled()
+
+        self.assertEqual('SUCCESS',
+                         self.getJobFromHistory('project-test1').result)
+        self.assertEqual('SUCCESS',
+                         self.getJobFromHistory('project-test2').result)
+
+        job = self.getJobFromHistory('project-test2')
+        zuulvars = job.parameters['vars']['zuul']
+        self.assertEqual(pr.number, zuulvars['change'])
+        self.assertEqual(pr.head_sha, zuulvars['patchset'])