1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# 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 /status
GET('/status', {})
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))
|