Skip to content
Snippets Groups Projects
Commit 8ddce34f7bbd authored by Georges Racinet's avatar Georges Racinet
Browse files

Readthedocs: testing the integration

It's similar to the existing web hooks tests: we're really
listening to the POSTed data. One reason that is possible
is that integration/service has a full URL field, instead
of just project name and id on Read the docs.
parent aac126bae6b9
No related branches found
No related tags found
1 merge request!39New tests for Heptapod 0.13.1
Pipeline #6739 passed
import json
from urllib.parse import parse_qs
import pytest
from .utils import needs
......@@ -121,6 +122,49 @@
assert commit['hgid'] == hgsha
@needs.reverse_call
def test_readthedocs_hook(tmpdir, test_project):
"""Setup the readthedocs integration, push and assert what was posted.
There's no point pushing on several named branches: each will be
considered a new event on the GitLab side, giving rise to as many
POST requests to Read the Docs.
"""
listener = HttpListener(test_project.heptapod)
repo_path = tmpdir.join('repo1')
url = test_project.owner_basic_auth_url
token = "rtdtkxxx"
resp = test_project.owner_api_put(
subpath='services/readthedocs',
data=dict(
project_url=listener.url(test_project.heptapod),
token=token,
# TLS verification seems inert over plain HTTP
active=True,
)
)
assert resp.status_code < 400
repo = LocalRepo.init(repo_path)
repo_path.join('foo').write('foo0')
repo.hg('commit', '-Am', "Commit 0")
repo.hg('branch', 'other')
repo.hg('push', '--publish', url)
timeout = 30
exit_code = listener.join(timeout)
assert exit_code is not None, "No request received in %d seconds" % timeout
posted = listener.queue.get()
environ = posted['environ']
# otherwise this test would be in trouble:
assert environ['CONTENT_TYPE'] == 'application/x-www-form-urlencoded'
hook_data = parse_qs(posted['body'].decode())
assert hook_data['branches'] == ['default']
assert hook_data['token'] == [token]
@needs.fs_access
@parametrize('push_proto', ['ssh', 'http'])
def test_push_hook_env(test_project, tmpdir, push_proto):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment