From 161cd6ead960ecf6afc05bd583718724140d6973 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sat, 6 Apr 2019 15:08:44 +0300 Subject: Refactor: use name V instead of vars in yarn implements vars is a Python builtin, and as such it's not a great name. --- yarns/900-implements.yarn | 56 +++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'yarns/900-implements.yarn') diff --git a/yarns/900-implements.yarn b/yarns/900-implements.yarn index 5468a6c..490f46e 100644 --- a/yarns/900-implements.yarn +++ b/yarns/900-implements.yarn @@ -33,46 +33,46 @@ along with this program. If not, see . user = get_next_match() path = get_next_match() token = get_token(user) - url = vars['url'] - http(vars, get, url + path, token=token) + url = V['url'] + http(V, get, url + path, token=token) IMPLEMENTS WHEN (\S+) retrieves (\S+) from artifact store user = get_next_match() path = get_next_match() token = get_token(user) - url = vars['bsurl'] - http(vars, get_blob, url + path, token=token) + url = V['bsurl'] + http(V, get_blob, url + path, token=token) IMPLEMENTS WHEN (\S+) makes request GET (\S+) with an invalid token user = get_next_match() path = get_next_match() token = get_token(user) - url = vars['url'] - http(vars, get, url + path, token='invalid') + url = V['url'] + http(V, get, url + path, token='invalid') IMPLEMENTS WHEN (\S+) makes request POST (\S+) with a valid token and body (.+) user = get_next_match() path = get_next_match() body = get_next_match() token = get_token(user) - url = vars['url'] - http(vars, post, url + path, body=body, token=token) + url = V['url'] + http(V, post, url + path, body=body, token=token) IMPLEMENTS WHEN (\S+) makes request POST (\S+) with an invalid token and body (.+) user = get_next_match() path = get_next_match() body = get_next_match() token = get_token(user) - url = vars['url'] - http(vars, post, url + path, body=body, token='invalid') + url = V['url'] + http(V, post, url + path, body=body, token='invalid') IMPLEMENTS WHEN (\S+) makes request PUT (\S+) with a valid token and body (.+) user = get_next_match() path = get_next_match() body = get_next_match() token = get_token(user) - url = vars['url'] - http(vars, put, url + path, body=body, token=token) + url = V['url'] + http(V, put, url + path, body=body, token=token) IMPLEMENTS WHEN (\S+) sends blob (\S+) to artifact store as (\S+) user = get_next_match() @@ -80,34 +80,34 @@ along with this program. If not, see . path = get_next_match() body = cat(filename) token = get_token(user) - url = vars['bsurl'] - http(vars, put_blob, url + path, body=body, token=token) + url = V['bsurl'] + http(V, put_blob, url + path, body=body, token=token) IMPLEMENTS WHEN (\S+) makes request PUT (\S+) with an invalid token user = get_next_match() path = get_next_match() body = '{}' token = get_token(user) - url = vars['url'] - http(vars, put, url + path, body=body, token='invalid') + url = V['url'] + http(V, put, url + path, body=body, token='invalid') IMPLEMENTS WHEN (\S+) makes request DELETE (\S+) user = get_next_match() path = get_next_match() token = get_token(user) - url = vars['url'] - http(vars, delete, url + path, token=token) + url = V['url'] + http(V, delete, url + path, token=token) ## HTTP response inspection IMPLEMENTS THEN result has status code (\d+) expected = int(get_next_match()) - assertEqual(expected, vars['status_code']) + assertEqual(expected, V['status_code']) IMPLEMENTS THEN body matches (.+) expected_text = get_next_match() expected = json.loads(expected_text) - actual = json.loads(vars['body']) + actual = json.loads(V['body']) print 'expected' json.dump(expected, sys.stdout, indent=4, sort_keys=True) print @@ -121,7 +121,7 @@ along with this program. If not, see . IMPLEMENTS THEN body text contains "(.*)" pattern = unescape(get_next_match()) - text = vars['body'] + text = V['body'] print 'pattern:', repr(pattern) print 'text:', text assertTrue(pattern in text) @@ -129,11 +129,11 @@ along with this program. If not, see . IMPLEMENTS THEN body is the same as the blob (\S+) filename = get_next_match() blob = cat(filename) - body = vars['body'] + body = V['body'] assertEqual(body, blob) IMPLEMENTS THEN version in body matches version from setup.py - body = vars['body'] + body = V['body'] obj = json.loads(body) actual = obj['version'] setup_py = os.path.join(srcdir, 'setup.py') @@ -143,13 +143,13 @@ along with this program. If not, see . IMPLEMENTS THEN result has header (\S+): (\S+) name = get_next_match() value = get_next_match() - headers = vars['headers'] + headers = V['headers'] assertEqual(headers[name].lower(), value.lower()) IMPLEMENTS THEN result is step (.+) step = json.loads(get_next_match()) print('expected step', step) - body = json.loads(vars['body']) + body = json.loads(V['body']) print('actual body', body) actual_step = body['step'] print('actual step', actual_step) @@ -160,14 +160,14 @@ along with this program. If not, see . IMPLEMENTS WHEN (\S+) requests list of builds user = get_next_match() token = get_token(user) - url = vars['url'] + url = V['url'] path = '/builds' - http(vars, get, url + path, token=token) + http(V, get, url + path, token=token) IMPLEMENTS THEN the list of builds is (.+) expected = set(json.loads(get_next_match())) print('expected', expected) - body = json.loads(vars['body'])['builds'] + body = json.loads(V['body'])['builds'] print('body', body) builds = set(build['build_id'] for build in body) assertEqual(builds, expected) -- cgit v1.2.1