def get_response(): """Instantiate a generic refget response Returns: (Response): generic refget response, compatible with refget functions """ return Response()
def prepare(self): """Instantiate the generic request and response passed to refget func the generic request is instantiated by converting the Tornado-specific request object, so that it will be compatible with refget functions """ self.g_request = self.get_generic_request() self.g_response = Response()
def test_data(key, value): response = Response() response.put_data(key, value) assert response.get_datum(key) == value assert response.get_data()[key] == value new_dict = {"dataA": "valueA", "dataB": "valueB"} response.update_data(new_dict) assert response.get_datum(key) == value assert response.get_data()[key] == value
def test_header(key, value): response = Response() response.put_header(key, value) assert response.get_header(key) == value assert response.get_headers()[key] == value new_dict = {"headerA": "valueA", "headerB": "valueB"} response.update_headers(new_dict) assert response.get_header(key) == value assert response.get_headers()[key] == value
def test_media_type_middleware(request_dict, exp_status_code): properties = Properties({}) request = setup_request(request_dict) response = Response() @MediaTypeMidware(properties, request, response) def dummy_function(properties, request, response): return None dummy_function(properties, request, response) assert response.get_status_code() == exp_status_code
def test_redirect(url): response = Response() response.set_redirect_found(url) assert response.get_status_code() == SC.REDIRECT_FOUND assert response.get_header("Location") == url
def test_status_code(status_code): response = Response() response.set_status_code(status_code) assert response.get_status_code() == status_code
def test_body(body): response = Response() response.set_body(body) assert response.get_body() == body
def setup_properties_request_response(props_dict, request_dict): return [ setup_properties(props_dict), setup_request(request_dict), Response() ]