From 63d9308284c417accbe9b8abfadcd67ad9d17957 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Thu, 21 Feb 2019 01:18:32 +0100 Subject: test_task: simplify getting user login --- kpov_judge/test_task.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'kpov_judge') diff --git a/kpov_judge/test_task.py b/kpov_judge/test_task.py index 4e9561f..aa9a268 100755 --- a/kpov_judge/test_task.py +++ b/kpov_judge/test_task.py @@ -181,16 +181,18 @@ if __name__ == '__main__': if not tokens.get(task_name): # get the student's ID and password # TODO clunky, should refactor all argument-getting stuff - fetch_params_meta = {'username': {'descriptions': {'si': 'Uporabniško ime', 'en': 'Username'}}} - params = get_params(params, fetch_params_meta, params['language']) - fetch_pass_meta = {'password': {'descriptions': {'si': 'Geslo', 'en': 'Password'}, 'masked': True}} - params_pass = get_params({}, fetch_pass_meta, params['language']) + user_meta = collections.OrderedDict(( + ('username', {'descriptions': {'si': 'Uporabniško ime', 'en': 'Username'}}), + ('password', {'descriptions': {'si': 'Geslo', 'en': 'Password'}, 'masked': True}), + )) + user_params = get_params(params, user_meta, params['language']) - http_auth(task_url, params['username'], params_pass['password']) + http_auth(task_url, user_params['username'], user_params['password']) response = urllib.request.urlopen('{task_url}/{task_name}/token.json'.format(**params)) response = json.load(io.TextIOWrapper(response)) if response: tokens[task_name] = response['token'] + params['username'] = user_params['username'] except Exception as ex: print(ex) -- cgit v1.2.1