h2non/pook

JSON subset matching

sarayourfriend opened this issue · 0 comments

It would be nice to be able to match request body JSON using an expected subset of the data. Something like:

(pook.post(url)
    .json({"id": identifier}, subset=True)
    .reply(200))

As a way to match a larger request body that's:

{
  "id": ...,
  "created_on": ...,
  "updated_on": ...,
  "other_property_irrelevant_to_the_test": ...,
}

Right now the only way to do this is using a regex pattern with the body matcher, but that's pretty tedious, especially if you have multiple subset properties you want to test.