Closed
Description
Hi @lundberg 👋
I want to let you know that #240 (or 0.20.2
in general) broke our tests - but I think that's good. I want to tell you how we used it and what actually broke as I think that there's a room for small improvement.
We had our mocks defined as:
respx_mock.get("https://example.com/orders?storeId=1&status=paid&status=reviewed")
And change from #240 (or 0.20.2
) made us rewrite them as
respx_mock.get(
"https://example.com/orders",
params={
"storeId": "1",
"status":[
"paid",
"reviewed"
]
}
)
I believe that up until now, we used this bug
to our advantage.
I inspected what was happening under the hood in 0.20.2
and it turns out that:
First one:
Request: <Request('GET', 'https://example.com/api/orders?storeId=1&status=paid&status=reviewed')>
Pattern: <Scheme eq 'https'> AND <Host eq 'example.com'> AND <Path eq '/api/orders?storeId=1&status=paid&status=reviewed'> AND <Method eq 'GET'>
Match: <Match False>
and second one:
Request: <Request('GET', 'https://example.com/orders?storeId=1&status=paid&status=reviewed')>
Pattern: <Scheme eq 'https'> AND <Host eq 'example.com'> AND <Path eq '/api/orders'> AND <Method eq 'GET'> AND <Params contains QueryParams('storeId=1&status=paid&status=reviewed')>
Match: <Match True>
These are obviously two different sets of patterns to match.
As a follow up to this issue I want to ask:
- Can we document this in
caveat
section of documentation? I think there might be some folks doing the same error as we did and this could save them hours or days of debugging. - Was this behavior expected?
- Do you plan to make querystrings produce identical set of patterns?
- ie:
whenthenrespx_mock.get("https://example.com/orders?storeId=1&status=paid&status=reviewed")
Request: <Request('GET', 'https://example.com/orders?storeId=1&status=paid&status=reviewed')> Pattern: <Scheme eq 'https'> AND <Host eq 'example.com'> AND <Path eq '/api/orders'> AND <Method eq 'GET'> AND <Params contains QueryParams('storeId=1&status=paid&status=reviewed')> Match: <Match True>
- ie:
Metadata
Metadata
Assignees
Labels
No labels