[IMP] *: move the page helper fixture to the shared conftest

Use it in `test_limit` instead of direct `requests` calls.
This commit is contained in:
Xavier Morel 2024-06-26 14:34:34 +02:00
parent 1c76a675c2
commit de32824a62
3 changed files with 12 additions and 16 deletions

View File

@ -385,6 +385,15 @@ def port():
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
return s.getsockname()[1]
@pytest.fixture
def page(port):
with requests.Session() as s:
def get(url):
r = s.get('http://localhost:{}{}'.format(port, url))
r.raise_for_status()
return r.content
yield get
@pytest.fixture(scope='session')
def dummy_addons_path():
with tempfile.TemporaryDirectory() as dummy_addons_path:

View File

@ -1,5 +1,4 @@
import pytest
import requests
from utils import seen, Commit, make_basic, to_pr
@ -9,7 +8,7 @@ from utils import seen, Commit, make_basic, to_pr
pytest.param('b', 'b', 0, id='current'),
pytest.param('b', 'a', 0, id='earlier'),
])
def test_configure_fp_limit(env, config, make_repo, source, limit, count, port):
def test_configure_fp_limit(env, config, make_repo, source, limit, count, page):
prod, other = make_basic(env, config, make_repo, statuses="default")
with prod:
[c] = prod.make_commits(
@ -35,15 +34,13 @@ def test_configure_fp_limit(env, config, make_repo, source, limit, count, port):
assert not descendants.limit_id, "descendant should not inherit the limit explicitly"
# check that the basic thingie works
r = requests.get(f'http://localhost:{port}/{prod.name}/pull/{pr.number}.png')
assert r.ok, r.text
page(f'/{prod.name}/pull/{pr.number}.png')
if descendants:
c = env['runbot_merge.branch'].search([('name', '=', 'c')])
descendants.limit_id = c.id
r = requests.get(f'http://localhost:{port}/{prod.name}/pull/{pr.number}.png')
assert r.ok
page(f'/{prod.name}/pull/{pr.number}.png')
def test_ignore(env, config, make_repo, users):
""" Provide an "ignore" command which is equivalent to setting the limit

View File

@ -1,19 +1,9 @@
import pytest
import requests
@pytest.fixture()
def module():
return 'runbot_merge'
@pytest.fixture
def page(port):
s = requests.Session()
def get(url):
r = s.get('http://localhost:{}{}'.format(port, url))
r.raise_for_status()
return r.content
return get
@pytest.fixture
def default_crons():
return [