async def fan_sensors(request): """Get fan sensor data for autofan. FIXME: this is a temporary route for autofan -- this should be generalized and we can add it back into mainline synse server. """ result = await commands.fan_sensors() return json(result)
def test_json_pretty(data, expected): """Test parsing dict to a pretty JSON string.""" config.options.set('pretty_json', True) actual = response.json(data) assert isinstance(actual, HTTPResponse) assert expected == actual.body
def to_json(self): """Convert the response scheme data to JSON. Returns: sanic.HTTPResponse: The Sanic endpoint response with the given body encoded as JSON. """ return json(self.data)
def _make_error(error_id, exception): """Make a JSON error response.""" error = { 'http_code': exception.status_code, 'error_id': error_id, 'description': errors.codes[error_id], 'timestamp': utils.rfc3339now(), 'context': str(exception) } return json(error, status=exception.status_code)
def test_json(data, expected): """Test parsing dict to JSON string.""" actual = response.json(data) assert isinstance(actual, HTTPResponse) assert expected == actual.body