blob: a760cc7733cf062ab8447ccafc804d9d30f5c2df [file] [log] [blame]
Azule2972542015-03-29 14:06:28 +01001from lettuce import step, world
2import requests
3import os
4
5endpoint = "http://%s:5000" % os.environ['BOOT2DOCKERIP']
6
7
8@step("I create a new topic using POST /(.*)")
9def create_topic(step, topic):
10 world.message_response = requests.post(
11 '%s/%s' % (endpoint, topic), data='subscribe')
12 assert world.message_response.status_code == 200, \
13 "Got %s" % world.message_response.status_code
14
15
16@step("I publish a message '(.*)' with a POST /(.*)")
17def publish(step, message, topic):
18 world.message_response = requests.post(
19 '%s/%s' % (endpoint, topic), data=message)
20 assert world.message_response.status_code == 200, \
21 "Got %s" % world.message_response.status_code
22
23
24@step("I subscribe using POST /(.*)/(.*)")
25def subscribe(step, topic, user):
26 world.message_response = requests.post(
27 '%s/%s/%s' % (endpoint, topic, user))
28 assert world.message_response.status_code == 200, \
29 "Got %s" % world.message_response.status_code
30
31
32@step("I unsubscribe using DELETE /(.*)/(.*)")
33def unsubscribe(step, topic, user):
34 world.message_response = requests.delete(
35 '%s/%s/%s' % (endpoint, topic, user))
36
37
38@step("get new messages using GET /(.*)/(.*)")
39def read_next(step, topic, user):
40 world.message_response = requests.get(
41 '%s/%s/%s' % (endpoint, topic, user))
42
43
44@step("discard the first 'subscribe' message from /(.*)/(.*)")
45def discard_next(step, topic, user):
46 world.message_response = requests.get(
47 '%s/%s/%s' % (endpoint, topic, user))
48
49
50@step("I should get a (.*) back")
51def check_message_http_code(step, expected):
52 assert world.message_response.status_code == int(expected), \
53 "Got %s" % world.message_response.status_code
54
55
56@step("I should see '(.*)' in the body of the message")
57def check_message_body(step, expected):
58 assert world.message_response.content == expected, \
59 "Got %s" % world.message_response.content
60
61
62@step("I should receive nothing")
63def check_that_I_receive_nothing(step):
64 assert world.message_response.content == '', \
65 "Got %s" % world.message_response.content
66
67
68@step("The subscription does not exist")
69def pass_the_subscription_does_not_exist(step):
70 pass
71