def test_json_argument(self, Request):
        patch_requests()

        requests.post(
            'http://127.0.0.1:5000/api',
            json={
                'foo': ['bar'],
                'baz': 42
            }
        )

        args, kwargs = Request.call_args
        self.assertEquals(kwargs['data'], '{"foo": ["bar"], "baz": 42}')
        self.assertEquals(kwargs['headers']['Content-type'], 'application/json')

        unpatch_requests()
Exemplo n.º 2
0
            }
        })

class Request(flask.Request):
    def on_json_loading_failed(self, e):
        raise APIError("Could not decode the JSON payload")

class Flask(flask.Flask, FlaskRESTMixin):
    request_class = Request

class Blueprint(flask.Blueprint, BlueprintRESTMixin):
    pass

EVENT_QUEUE_NAME = 'events'

patch_requests()

connection = Connection()
database = connection.bursts

event_categories = database.event_categories
subscribers = database.subscribers

event_queue = Client(['localhost:22133'])

class UUIDConverter(BaseConverter):
    def to_python(self, string):
        return UUID(hex=string)

    def to_url(self, uuid):
        return uuid.hex