diff options
author | Lars Wirzenius <liw@liw.fi> | 2018-10-27 12:58:00 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2018-10-28 10:10:47 +0200 |
commit | 8f5c7b0fc2b273e55b2116ddece21ac2c19fa863 (patch) | |
tree | 7f12c091b7ec63b2953695cee3f9be3685d4373d /yarns/900-implements.yarn | |
parent | cc2d1b21e67643e237d968793d31b7b9437a1640 (diff) | |
download | muck-poc-8f5c7b0fc2b273e55b2116ddece21ac2c19fa863.tar.gz |
Add: HTTP API, with scenario tests
Diffstat (limited to 'yarns/900-implements.yarn')
-rw-r--r-- | yarns/900-implements.yarn | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/yarns/900-implements.yarn b/yarns/900-implements.yarn new file mode 100644 index 0000000..7eb0c86 --- /dev/null +++ b/yarns/900-implements.yarn @@ -0,0 +1,69 @@ +# Scenario step implementations + +## Start and stop Muck + + IMPLEMENTS GIVEN a running Muck + start_muck() + + IMPLEMENTS WHEN Muck is restarted + stop_muck() + start_muck() + + IMPLEMENTS FINALLY Muck is stopped + stop_muck() + +## HTTP requests + + IMPLEMENTS WHEN user makes request POST /res with body (.*) + body = get_expanded_match() + POST('/res', {}, json.loads(body)) + + IMPLEMENTS WHEN user makes request GET /res with header "(\S+): (.+)" + header = get_expanded_match() + value = get_expanded_match() + GET('/res', {header:value}) + + IMPLEMENTS WHEN user makes request GET /search with body (.+) + body = json.loads(get_expanded_match()) + GET('/search', {}, body=body) + + IMPLEMENTS WHEN user makes request PUT /res with header "(\S+): (.+)" and header "(\S+): (.+)" and body (.+) + header1 = get_expanded_match() + value1 = get_expanded_match() + header2 = get_expanded_match() + value2 = get_expanded_match() + body = get_expanded_match() + headers = { + header1: value1, + header2: value2, + } + PUT('/res', headers, json.loads(body)) + + IMPLEMENTS WHEN user makes request DELETE /res with header "(\S+): (.+)" + header = get_expanded_match() + value = get_expanded_match() + DELETE('/res', {header:value}) + +## Checking HTTP responses + + IMPLEMENTS THEN status code is (\d+) + expected = int(get_expanded_match()) + assertEqual(V['status_code'], expected) + + IMPLEMENTS THEN remember resource id as (\S+) + name = get_next_match() + save_header('Muck-Id', name) + + IMPLEMENTS THEN remember resource revision as (\S+) + name = get_next_match() + save_header('Muck-Revision', name) + + IMPLEMENTS THEN response has header "(\S+): (.+)" + name = get_next_match() + expected = get_expanded_match() + assertEqual(get_header(name), expected) + + IMPLEMENTS THEN response body is (.+) + expected = get_expanded_match() + print 'expected:', expected + assertEqual(get_json_body(), json.loads(expected)) |