Read about our upcoming Code of Conduct on this issue

Commit 35ef8e55 authored by Georges Racinet's avatar Georges Racinet 🦑
Browse files

New utility to check a given web page isn't an error.

Using in in `test_push.py` for now, but this is a long waiting
dedup.
parent b43e837cb95c
......@@ -4,7 +4,10 @@ import pytest
import re
import requests
from .utils import needs
from .utils import (
assert_webdriver_not_error,
needs,
)
from .utils.reverse_calls import HttpListener
from .utils.hg import LocalRepo
from .utils.project import (
......@@ -79,12 +82,7 @@ def test_push_webdriver(test_project, tmpdir):
webdriver = test_project.owner_webdriver
webdriver.get('/'.join((test_project.url, 'commit',
branches['branch/default']['commit']['id'])))
# we don't have a reliable way to detect an error
# the title would be just 500 in production and the error class name in
# development mode.
assert "Error" not in webdriver.title
assert "(500)" not in webdriver.title
assert_webdriver_not_error(webdriver)
assert 'Commit 0' in webdriver.title
hgsha = repo.hg('log', '-T', '{node}', '-r', '0')
......
......@@ -33,3 +33,16 @@ def wait_assert(get_info, condition, timeout=10, retry_wait=0.2, msg=None):
def unique_name(name):
return '%s_%s' % (name, str(time.time()).replace('.', '_'))
def assert_webdriver_not_error(webdriver):
"""assert that the current page is not GitLab's error page rendering.
We don't have a reliable way to detect an error
The page title would be just 500 in production and the error class name in
# development mode.
"""
title = webdriver.title
assert "Error" not in title
assert not any(("(%d)" % code) in title
for code in (500, 502, 504, 403, 404))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment