@httpretty.activate
    def test_delete_hook_fail(self):
        git_hub = GitHub(self.URL, self.OAUTH2_TOKEN)

        # Test where repo does not exist
        self.register_repo_check(self.callback_repo_check)
        with self.assertRaises(GitHubRepoDoesNotExist):
            git_hub.delete_web_hooks(self.ORG, self.TEST_REPO)

        self.register_repo_check(
            partial(self.callback_repo_check, status_code=200)
        )

        # Test no hooks to delete
        self.register_hook_list(status=404)
        git_hub = GitHub(self.URL, self.OAUTH2_TOKEN)
        # Will raise if hooks are found since I haven't registered
        # the hook delete URL.
        num_deleted_hooks = git_hub.delete_web_hooks(self.ORG, self.TEST_REPO)
        self.assertEqual(0, num_deleted_hooks)

        # Set list to return on hook that we have registered for
        # explicitly
        self.register_hook_list(body=json.dumps(
            [{
                'url': '{url}repos/{org}/{repo}/hooks/1'.format(
                    url=self.URL, org=self.ORG, repo=self.TEST_REPO
                )
            }]
        ))
        # Reregister ``repo_check`` 200
        self.register_repo_check(
            partial(self.callback_repo_check, status_code=200)
        )
        # Fail the deletion
        self.register_hook_delete(status=422)
        with self.assertRaisesRegexp(GitHubUnknownError, ''):
            git_hub.delete_web_hooks(self.ORG, self.TEST_REPO)
Test the deletion of hooks
dataset/ETHPy150Open mitodl/orcoursetrion/orcoursetrion/tests/test_github.py/TestGithub.test_delete_hook_fail