Commit 9ea7ec64 authored by Georges Racinet's avatar Georges Racinet 🦑
Browse files

Project: new api_get_field() helper method

This will help reducing the boiler plate and over long statements.
Leveraging in test_import for immediate testing.
parent 1be6ef44567d
...@@ -44,9 +44,8 @@ def prepare_import_source(project, tmpdir, tweak_hgrc=True): ...@@ -44,9 +44,8 @@ def prepare_import_source(project, tmpdir, tweak_hgrc=True):
'--user', 'Raphaël <raphael@heptapod.test>') '--user', 'Raphaël <raphael@heptapod.test>')
repo.hg('push') repo.hg('push')
resp = project.owner_api_get() project_external_url = project.api_get_field('http_url_to_repo')
assert resp.status_code == 200 assert project_external_url is not None
project_external_url = resp.json()['http_url_to_repo']
return repo, project_external_url return repo, project_external_url
......
...@@ -144,6 +144,15 @@ class Project(object): ...@@ -144,6 +144,15 @@ class Project(object):
""" """
return self.owner_api_request('DELETE', **kwargs) return self.owner_api_request('DELETE', **kwargs)
def api_get_field(self, key):
"""Return the value of a field by performing an API GET request.
The request is made with full owner credentials.
"""
resp = self.owner_api_get()
assert resp.status_code < 400
return resp.json().get(key)
@property @property
def owner_credentials(self): def owner_credentials(self):
"""Return (user, password).""" """Return (user, password)."""
......
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