Beispiel #1
0
 def test_it_supports_patch_requests_with_payload(self):
     url = "http://abc.de"
     r = LocustRequest.from_request(
         Request(
             timestamp=MagicMock(),
             method=HttpMethod.PATCH,
             url=urlparse(url),
             har_entry={"entry": "data"},
             headers={"a": "b"},
             query=[QueryPair("c", "d")],
             post_data={
                 "mimeType": "application/json",
                 "params": [{"name": "x", "value": "y"}],
                 "text": """{"z": 7}""",
             },
         )
     )
     assert lreq_to_expr(r) == py.FunctionCall(
         name="self.client.patch",
         named_args={
             "url": py.Literal(url),
             "name": py.Literal(url),
             "headers": py.Literal({"a": "b"}),
             "timeout": py.Literal(TIMEOUT),
             "allow_redirects": py.Literal(False),
             "json": py.Literal({"z": 7}),
             "params": py.Literal([(b"x", b"y"), (b"c", b"d")]),
         },
     )
Beispiel #2
0
 def test_it_supports_get_requests(self):
     url = "http://abc.de"
     r = Request(
         timestamp=MagicMock(),
         method=HttpMethod.GET,
         url=urlparse(url),
         har_entry={"entry": "data"},
         headers={"a": "b"},
         query=[QueryPair("x", "y")],  # query is currently ignored for GET
     )
     assert req_to_expr(r) == py.FunctionCall(
         name="self.client.get",
         named_args={
             "url": py.Literal(url),
             "name": py.Literal(url),
             "headers": py.Literal({"a": "b"}),
             "timeout": py.Literal(TIMEOUT),
             "allow_redirects": py.Literal(False),
         },
     )
Beispiel #3
0
 def test_it_supports_patch_requests_without_payload(self):
     url = "http://abc.de"
     r = Request(
         timestamp=MagicMock(),
         method=HttpMethod.PATCH,
         url=urlparse(url),
         har_entry={"entry": "data"},
         headers={"a": "b"},
         query=[QueryPair("c", "d")],
         post_data=None,
     )
     assert req_to_expr(r) == py.FunctionCall(
         name="self.client.patch",
         named_args={
             "url": py.Literal(url),
             "name": py.Literal(url),
             "headers": py.Literal({"a": "b"}),
             "timeout": py.Literal(TIMEOUT),
             "allow_redirects": py.Literal(False),
             "params": py.Literal([(b"c", b"d")]),
         },
     )