Skip to content

Commit

Permalink
CI: implement user get-by-username
Browse files Browse the repository at this point in the history
fixes #95
  • Loading branch information
Gauvain Pocentek committed Feb 14, 2016
1 parent 7260684 commit 58433d2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
7 changes: 7 additions & 0 deletions docs/cli.rst
Expand Up @@ -150,6 +150,13 @@ Get a specific project (id 2):
$ gitlab project get --id 2
Get a specific user by id or by username:

.. code-block:: console
$ gitlab user get --id 3
$ gitlab user get-by-username --query jdoe
Get a list of snippets for this project:

.. code-block:: console
Expand Down
11 changes: 9 additions & 2 deletions gitlab/cli.py
Expand Up @@ -47,7 +47,8 @@
'all': {}},
gitlab.User: {'block': {'required': ['id']},
'unblock': {'required': ['id']},
'search': {'required': ['query']}},
'search': {'required': ['query']},
'get-by-username': {'required': ['query']}},
}


Expand Down Expand Up @@ -229,6 +230,12 @@ def do_user_search(self, cls, gl, what, args):
except Exception as e:
_die("Impossible to search users (%s)" % str(e))

def do_user_getbyusername(self, cls, gl, what, args):
try:
return gl.users.search(args['query'])
except Exception as e:
_die("Impossible to get user %s (%s)" % (args['query'], str(e)))


def _populate_sub_parser_by_class(cls, sub_parser):
for action_name in ['list', 'get', 'create', 'update', 'delete']:
Expand Down Expand Up @@ -370,7 +377,7 @@ def main():
cli = GitlabCLI()
method = None
what = what.replace('-', '_')
action = action.lower()
action = action.lower().replace('-', '')
for test in ["do_%s_%s" % (what, action),
"do_%s" % action]:
if hasattr(cli, test):
Expand Down
8 changes: 8 additions & 0 deletions tools/functional_tests.sh
Expand Up @@ -35,6 +35,14 @@ testcase "user creation" '
'
USER_ID=$(pecho "${OUTPUT}" | grep ^id: | cut -d' ' -f2)

testcase "user get (by id)" '
GITLAB user get --id $USER_ID >/dev/null 2>&1
'

testcase "user get (by username)" '
GITLAB user get-by-username --query user1 >/dev/null 2>&1
'

testcase "verbose output" '
OUTPUT=$(try GITLAB -v user list) || exit 1
pecho "${OUTPUT}" | grep -q avatar-url
Expand Down

0 comments on commit 58433d2

Please sign in to comment.