def test_create_topic(self, res):
     name = 'name'
     kwargs = {'arg1': 'arg1', 'arg2': 'arg2'}
     result = self.client.create_topic(name, **kwargs)
     res.assert_called_with(
         'PUT', 'topics/name',
         data=json.dumps(kwargs))
     self.assertEqual(result, res().json)
 def test_create_subscription(self, res):
     type_ = 'http'
     options = {'arg1': 'arg1', 'arg2': 'arg2'}
     result = self.topic.create_subscription(type_, **options)
     subscription = {"endpoint_type": type_, "endpoint": options}
     res.assert_called_with(
         'POST', 'subscriptions',
         data=json.dumps(subscription))
     self.assertEqual(result, res().json)
 def test_push(self, res):
     message_body = "body"
     message_options = {'option_a': 'a', 'option_b': 'b'}
     result = self.topic.push(message_body, **message_options)
     json_doc = {'body': 'body', 'option_a': 'a', 'option_b': 'b'}
     res.assert_called_with(
         'POST', 'messages',
         data=json.dumps(json_doc))
     self.assertEqual(result, res().json)
 def create_topic(self, name, **kwargs):
     topic = {}
     topic.update(kwargs)
     data = json.dumps(topic)
     r = self.put("topics/%s" % (name, ), data=data)
     return r.json
 def create_queue(self, name, **kwargs):
     queue = {}
     queue.update(kwargs)
     data = json.dumps(queue)
     r = self.put("queues/%s" % (name, ), data=data)
     return r.json
 def create_subscription(self, type_, **kwargs):
     r = self.post('subscriptions', data=json.dumps(
         {'endpoint_type': type_, 'endpoint': kwargs}))
     return r.json
 def push(self, body, **kwargs):
     message = {'body': body}
     message.update(kwargs)
     r = self.post("messages", data=json.dumps(message))
     return r.json
 def modify(self, **kwargs):
     topic = {}
     topic.update(kwargs)
     data = json.dumps(topic)
     r = self.put(data=data)
     return r.json
 def test_modify_queue(self, res):
     kwargs = {'arg1': 'arg1', 'arg2': 'arg2'}
     result = self.topic.modify(**kwargs)
     res.assert_called_with('PUT', data=json.dumps(kwargs))
     self.assertEqual(result, res().json)
 def modify(self, **kwargs):
     queue = {}
     queue.update(kwargs)
     data = json.dumps(queue)
     r = self.put(data=data)
     return r.json