def test_create_item_from_context(self):
     context = HttpRequestContext(
         host="https://www.google.com",
         url_path="/items/",
         method="POST",
         body_params={"name": "mi nombre", "description": "algo"}
     )
     response = request_from_context(context=context)
     self.assertEqual(response.status, 404)
 def test_create_item_from_context_with_cookie(self):
     c = Cookie({"Set-Cookie": "new_param=marcos; another_new=ivan"})
     context = HttpRequestContext(
         host="https://www.google.com",
         url_path="/items/",
         method="POST",
         body_params={"name": "mi nombre", "description": "algo"},
         cookie=c
     )
     response = request_from_context(context=context)
     self.assertEqual(response.status, 404)
示例#3
0
def sequential_requests(entries, update_dynamic_elements=False, **kwargs):
    req_res = []
    prev_response_context = None
    response = None
    for entry in entries:
        context = entry.request.as_http_request_context()
        if update_dynamic_elements:
            context = _update_dynamic_elements(
                prev_response_ctx=prev_response_context,
                response_ctx=response,
                request_ctx=context)
        for k, v in kwargs.items():
            setattr(context, k, v)
        response = http.request_from_context(context=context)
        prev_response_context = entry.response.as_http_response()

        req_res.append((context, response))

    return req_res