Remove all code and add a deprecation notice to the README. This should
make it really clear that we've moved.
Change-Id: Ic554437cf34fda7211ddfd2bb9d5f799f80a3096
Convert the tox jobs to Zuul v3 native and move them here.
Use tox environment instead of openstack-tox since upper-constraint
is not needed.
Change-Id: Ic933cf202d20625e692c9ec40584ca6bc12f7da5
Needed-By: Ie295a23c5921e9213ccef31367d642eec2288ef3
Include all supported Python versions as trove classifiers. Helps
library users know, at a glance, if the library can be integrated with
a project.
Remove Python 2.6 trove classifier, support was removed in
9bcf955af8dd62aa52c86e48a4868d2725353531
Also add trove classifier for PyPy as it is included in the tox test
matrix.
Change-Id: Iff7dcec47260006b325e3059cfaf8b8e912d2318
Similar to decorating a class, should create a separate mock copy
otherwise it acts as a caching decorator and any mock responses added
on each call will be present for subsequent calls.
Change-Id: Iabd70aa457ceb4dbc147d7cbaeec913148cb3b56
It really should have gone in with the review that implemented the
feature but better late than never.
Change-Id: Iafcfd17b9ddad8c09d66aadb6eda6f5603c23b8b
There was no documentation on how to use the exc= parameter. Add some
simple docs so people at least know that it's there.
Change-Id: I743e6899c2fe611790a7880bd909bb1260f9de52
Closes-Bug: #1625580
When creating a response we type check that the user has passed the
correct type to content and text, however we check this based on whether
the value is True and not whether it has been passed at all which means
that the empty string of the wrong type can incorrectly pass through
this check.
Fix this check to test the empty string.
Anyone relying on this passing will be caught with a more confusing
TypeError later and so this should be backwards compatible.
Change-Id: I826da9b7fd83bb88af50e4a96a5e6358ee35e4b2
Closes-Bug: #1647880
To handle requests for additional features on matching add a callback
function that can match anything on the request object. This is easier
than adding every combination of matcher option - though we should still
add things that are commonly used.
Change-Id: I300f74a1f2103545eca60087b2352a535add188d
Closes-Bug: #1657308
The double mocking solution we have now of mocking send and get_adapter
is a bit unusual. One of the problems is that if you have a nested mock
situation then send calling the last send means get_adapter is remocked
again and the outer adapter ends up being the last installed.
To avoid this always go to the real original send function to bypass any
outer installed mockers and make sure our get_adapter function is
triggered.
Change-Id: I47bff5e7da98e5238bd926e22845a7ca34f21940
Closes-Bug: #1642690
The old FakeHTTPResponse we're using in the tests is really basic and
lacks a lot of the information that is expected in a response from an
adapter. This is a hard problem that we've already solved in the
create_response function so use that to create a test response instead
of a custom solution here.
Change-Id: I2999c9c69b4e9ad895114fab8ae7f8ce275fa2a4
Closes-Bug: #1642697
Using request.netloc can be confusing because you have to check whether
or not the port is included. We are going to want this seperation in
later patches so expose it on the request.
Change-Id: I2e4bad425fdbc2501727b295752900d4ce4086bc
The Request proxy object is growing bigger and already has its own
category of tests. Move each into their own file with some simplified
helpers for testing.
Change-Id: I0dcc5d8d09feaf3febfcc8a4d114973096279c51
The called_once function was added to the Matcher and the Adapter but
not the top level Mocker function.
Change-Id: I4daa839d931b44fa69133ace663d41c84796b4ba
Closes-Bug: #1630159
As part of review [1] the openstack build system assumes the layout of
the docs directories to be doc/build. This is not what requests-mock was
producing. Fix the docs building directories to make it work with the
build system again.
[1] Icb0c02dc5b6f7b5e248e0df6d6093c29535b08f3
Closes-Bug: #1630114
Change-Id: Iea93ecfb0506d5ccd0b79ad35f5677797fadf730
When you register a handler the type for text or data can be a string or
a callback that provides a string. By the time you get to
create_response this callback should have been called and only a string
can be passed.
This check originally would have been in place for when a callback was
run and the return value was not the expected type, however
create_response is a public function that can be used on its own.
Correct the exception to clarify in create_response you must pass a
string or bytes and not a callback.
Change-Id: I3e700afddc1f40454f69a564066495bfc77d91c8
Closes-Bug: #1627506
Mock has a useful feature called assert_called_once. We don't have the
asserts here, but having called_once as a property is an easy way to
emulate this.
Change-Id: I59dfb53830195e73884fa0ca8a43b1de91fa1425
When matching URLs both strings are always lowercased to provide case
insensitive matching. Whilst this makes sense for the protocol and the
host names it does not necessarily hold true for paths and query
strings.
A byproduct of this is that the lowercased strings are being reported in
request_history which makes it harder to verify requests you made.
We enable globally and per adapter setting case sensitive matching. This
is intended to become the default in future releases.
Change-Id: I7bde70a52995ecf31a0eaeff96f2823a1a6682b2
Closes-Bug: #1584008
Allow installing the additional requirements for using the fixture
contrib module using pip extras.
Closes-Bug: #1501665
Change-Id: I20510d8db35c3cfdc0bc2892675b04d224027c7e
If you set up requests_mock to catch all requests (which I would
recommend) you sometimes get caught with things like file:// paths that
should be allowed to reach the filesystem.
To do this we should allow you to add a matcher that says a specific
route can bypass the catch all and do a real request.
This is a bit of a layer violation but I thought it was easy to start
with, then realized why it wasn't.
Change-Id: Ic2516f78413b88a489c8d6bd2bc39b8ebb5bf273
Closes-Bug: #1501665
A HTTPResponse returns a b'' when you read from a closed socket. BytesIO
raises a ValueError. This only comes to light when you are specifically
reading past the end of the stream in a chunking scenario like
swiftclient does.
Change-Id: I67ed45252deac9472cfb011a5eb89130a3791d6b
Closes-Bug: #1616690
Add a new environment that will install the latest development version
of requests. This lets you check for anything new coming down that might
bite us in upcoming releases.
Change-Id: I3dfaf79c681c5c4075b387947d797285c011cb88
We've been using requests-mock in openstack testing now for quite some
time without issue. The interface has been stable since about 0.3.
Change the classifier to stable and the next release will be a 1.0
Change-Id: I8ab3121a04c2b69f2a9cef2f9d4d662b527387fb