Gitlab Community Edition Instance

Commit e22c57a9 authored by xrotwang's avatar xrotwang Committed by Marcel Hellkamp
Browse files

Added public CDStar.GET method

Since the API is documented as REST API, it would be nice to have access
to generic HTTP methods, e.g. to retrieve archive status generically,
rather than through the more specialised methods like `list_files`.
parent 26c0678e
......@@ -119,11 +119,20 @@ class CDStar:
def GET(self, *path, **kw):
Public shortcut, e.g. to retrieve full archive metadata via
>>> api.GET(vault, archive, params=[('with', 'meta'), ('with', 'files')])
kw.setdefault('_expect_status', 200)
return self._rest('GET', *path, **kw).json()
def service_info(self):
return self._rest("GET").json()
return self.GET()
def vault_info(self, vault: str):
return self._rest("GET", vault).json()
return self.GET(vault)
def create_archive(self, vault, form: "FormUpdate" = None):
if form:
......@@ -22,6 +22,9 @@ def mockserver(mocker):
'cdstar': '3.0.0-SNAPSHOT'
elif method == 'GET' and len(args) == 1:
json = {'public': True}
return mocker.Mock(json=mocker.Mock(return_value=json))
return CDStar('', _session=MockSession())
......@@ -72,7 +72,12 @@ def test_crud_file():
# no commit
def test_init(mockserver):
def test_service_info2(mockserver):
si = mockserver.service_info()
assert si['version']['api'] == "3.0"
def test_vault_info2(mockserver):
vi = mockserver.vault_info('x')
assert 'public' in vi
Supports Markdown
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