...
 
Commits (4)
......@@ -98,8 +98,7 @@ def assert_merge_detected(project, mr_id, named_branch=None):
assert '500' not in webdriver.title
# detection worked
resp = project.session_api_get(webdriver,
subpath='merge_requests/' + mr_id)
resp = project.owner_api_get(subpath='merge_requests/%s' % mr_id)
assert resp.status_code == 200
mr = resp.json()
assert mr.get('state') == 'merged'
......
......@@ -15,10 +15,10 @@ def test_webdriver_destroy(test_project):
heptapod = test_project.heptapod
exit_code = heptapod.execute(
'ls -d ' + test_project.fs_common_path + '.hg')[0]
['ls', '-d ', test_project.fs_common_path + '.hg'])[0]
assert exit_code == 2
exit_code = heptapod.execute(
'ls -d ' + test_project.fs_common_path + '.wiki.hg')[0]
['ls', '-d ', test_project.fs_common_path + '.wiki.hg'])[0]
assert exit_code == 2
......@@ -40,6 +40,11 @@ def test_webdriver_create(heptapod, tmpdir):
assert branches['branch/default']['commit']['title'] == 'Commit 0'
finally:
if project is not None:
# TODO there are cases where the project is created, but
# our retrieval failed nevertheless, we should try and find
# it through the API to make sure we can clean it up in that
# case (spotted in first runs over Heptapod source, because
# of session cookie name being different)
project.api_destroy()
......
......@@ -40,6 +40,8 @@ class LocalRepo(object):
hgrc_extensions_lines = ("[extensions]",
"evolve =",
"topic = ",
"[ui]",
"username = Heptapod Tests <fonct@heptapod.test>"
)
def __init__(self, path):
......
......@@ -58,16 +58,22 @@ class Project(object):
"""
return requests.get(self.url, auth=self.owner_credentials, **kwargs)
def get_session_cookie(self, webdriver):
for cookie in webdriver.get_cookies():
if cookie['name'].startswith('_gitlab_session_'):
return cookie
raise LookupError("Could not find GitLab session cookie")
def session_api_get(self, webdriver, subpath='', **kwargs):
"""Perform a simple GET, with the session cookie found in webdriver.
The full URL is made of the API URL of the project, together with
the given subpath (example '/merge_requests/1')
"""
session = '_gitlab_session'
cookie = self.get_session_cookie(webdriver)
return requests.get(
'/'.join((self.api_url, subpath)),
cookies={session: webdriver.get_cookie(session)['value']})
cookies={cookie['name']: cookie['value']})
def api_edit(self, **params):
"""Perform a project API edit."""
......