Read about our upcoming Code of Conduct on this issue

Commit a7d48035 authored by Georges Racinet's avatar Georges Racinet 🦑
Browse files

Project: generalized use of api_get_field()

parent 6dd2c09a6700
......@@ -109,10 +109,8 @@ def test_group_restore(heptapod, breaks_concurrent, tmpdir):
project_name='test_proj',
user_name='test_basic',
group=group)
resp = project.owner_api_get()
assert resp.status_code == 200
assert resp.json()['path_with_namespace'] == '/'.join((
group.full_path, 'test_proj'))
assert project.api_get_field('path_with_namespace') == '/'.join(
(group.full_path, 'test_proj'))
group.put_hgrc(("[experimental]\n",
"groupconf=test\n"))
......
......@@ -29,9 +29,7 @@ def test_group_project(heptapod, hashed_storage):
project_name='test_proj',
user_name='test_basic',
group=group)
resp = project.owner_api_get()
assert resp.status_code == 200
assert resp.json()['path_with_namespace'] == '/'.join(
assert project.api_get_field('path_with_namespace') == '/'.join(
(group_name, 'test_proj'))
if not hashed_storage:
project.make_storage_legacy()
......@@ -83,9 +81,8 @@ def test_subgroups(heptapod, hashed_storage):
project_name='proj',
user_name='test_basic',
group=subgroup)
resp = project.owner_api_get()
assert resp.status_code == 200
assert resp.json()['path_with_namespace'] == group_name + '/sub/proj'
assert project.api_get_field(
'path_with_namespace') == group_name + '/sub/proj'
if not hashed_storage:
project.make_storage_legacy()
......
......@@ -325,9 +325,9 @@ class Project(object):
return dict((branch.pop('name'), branch) for branch in branches)
def api_default_branch(self):
resp = self.owner_api_get()
assert resp.status_code == 200, "project is broken, test can't proceed"
return resp.json()['default_branch']
branch = self.api_get_field('default_branch')
assert branch is not None
return branch
def api_branch_titles(self):
"""Keep only commit titles from `api_branches()`
......
......@@ -16,11 +16,16 @@ class Runner:
@classmethod
def api_register(cls, running_for, description):
"""Register the runner for a given scope of projects
:param running_for: currently only a :class:`Project` instance, should
eventually encompass :class:`Group` instances and the whole
Heptapod.
"""
heptapod = running_for.heptapod
resp = running_for.owner_api_get()
assert resp.status_code == 200
registration_token = resp.json()['runners_token']
registration_token = running_for.api_get_field('runners_token')
assert registration_token is not None
resp = requests.post(heptapod.api_url + '/runners',
data=dict(token=registration_token,
......
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