def test_github_api_ping_webhook_when_hook_doesnt_exist_raises_GitObjectNotFound(
        m_get_repo):
    class MockProject:
        def get_branch(self, name):
            return Mock()

        def get_hook(self, hook_id):
            assert hook_id == 123
            raise UnknownObjectException(404, data={'message': 'Not Found'})

    m_get_repo.return_value = MockProject()

    api = GithubAPI('github.com', 'owner', 'repository', 'my-branch')

    with raises(GitObjectNotFound):
        api.ping_webhook(123)
def test_github_api_ping_webhook(m_get_repo):
    class MockProject:
        def get_branch(self, name):
            return Mock()

        def get_hook(self, hook_id):
            assert hook_id == 123
            Mock(
                url=
                "https://api.github.com/repos/owner_name/myrepository/hooks/123",
                id=123)

    m_get_repo.return_value = MockProject()

    api = GithubAPI('github.com', 'owner', 'repository', 'my-branch')

    api.ping_webhook(123)