python-wiremock icon indicating copy to clipboard operation
python-wiremock copied to clipboard

Requests Problems [wiremock==2.6.1]

Open Gadzillion opened this issue 2 years ago • 0 comments
trafficstars

Proposal

  1. In WireMock we have method
def create_mapping(cls, mapping, parameters={}):
    cls.validate_is_entity(mapping, Mapping)
    response = cls.REST_CLIENT.post(
        cls.get_base_uri(cls.endpoint()),
        json=mapping.get_json_data(),
        headers=make_headers(),
        params=parameters,
    )
    response = cls.REST_CLIENT.handle_response(response)
    return MappingResponse.from_dict(response.json())

response is

{
  "id" : "48fbcb6c-eb02-49cb-8f14-479271ddf4fa",
  "request" : {
    "url" : "rest_ab",
    "method" : "GET"
  },
  "response" : {
    "status" : 200,
    "jsonBody" : {
      "a" : 1
    }
  },
  "uuid" : "48fbcb6c-eb02-49cb-8f14-479271ddf4fa",
  "persistent" : false,
  "priority" : 100
}

in my code

res = Mappings.create_mapping(mappings=mapping)
res_j = res.to_json() # {} - it's empty

why ? i want to get full response body with uuid and etc

    headers = {
        'Content-type': 'application/json',
        'X-Request-Id': str(uuid.uuid4())
    }
    request = MappingRequest(method=method, url=url, headers=headers)
    Mappings.create_mapping(mapping=mapping)
wiremock.exceptions.invalid_input_exception.InvalidInputException: {
  "errors" : [ {
    "code" : 10,
    "source" : {
      "pointer" : "/request/headers/Content-type"
    },
    "title" : "Error parsing JSON",
    "detail" : "\"application/json\" is not a valid match operation"
  } ]
}

Reproduction steps

all in Proposal

References

No response

Gadzillion avatar Sep 07 '23 08:09 Gadzillion