requests-mock icon indicating copy to clipboard operation
requests-mock copied to clipboard

1.8.0 --> 1.9.3 requote_uri breaking mocks with encoded URLS

Open shane-consensys opened this issue 4 years ago • 2 comments

Hey there,

I didn't have 1.8.0 pinned and noticed today that it was breaking previously working unit tests

    requests_mock.get(f'https://gitlab.com/api/v4/projects/{project_id}/repository/files/'
                      'project_configuration%2Fproject-configuration%2Ejson?ref=master',
                      headers={'Content-Type': 'application/json'},
                      text=('{"content": "ewoJInRlc3QiOiAidGVzdCIKfQ=="}'))

Using 1.9.3 this will fail with

No mock address: GET https://gitlab.com/api/v4/projects/1234567/repository/files/project_configuration%2Fproject-configuration%2Ejson?ref=master

For 1.8.0 it will work as expected. Obviously the change was made for intended reasons https://github.com/jamielennox/requests-mock/pull/169/files

but I'm just wondering since I couldn't see anything in the documentation about how to design the URLs in the mock to account for this

shane-consensys avatar Jun 10 '21 20:06 shane-consensys

Sorry this has been so long - i really am stuck here on what the best implementation should be. In general i try and match requests as much as possible, but i don't see one option here being better than another.

You're right though, it was supposed to be a minimal bug fix and should be communicated better.

What do you suggest?

jamielennox avatar Apr 20 '22 08:04 jamielennox

Hey sorry I'm no where near smart enough to suggest anything.

I just wonder for others though if there is a solution in how to format the url so it would work ? There will probably be a few developers hitting a similar issue with gitlab

shane-consensys avatar Apr 20 '22 08:04 shane-consensys