95 Commits

Author SHA1 Message Date
reedip
790dba4c0a Add trove support for py34 and remove py33
py33 has been deprecated from Mitaka so removing the
same from setup.cfg.
tox.ini supported py34 but setup.cfg did not, so adding
the change for the same.

Change-Id: I05c01df2022d3bdfb756cb47166ddc00a941c101
Closes-Bug: #1526170
2016-02-12 01:08:24 +00:00
Janonymous
9bcf955af8 Fix py34 DB issue and remove py33/py26
To solve the problem of "db type could
not be determined" on py34 we have to run first the py34 env to, then,
run py27. This patch puts py34 first on the tox.ini list of envs to
avoid this problem to happen. py33/py26 is not supported from Mitaka,
as per Infra, therefore removing the support for the same.

Closes-Bug: #1526170
Closes-bug: #1489059
Change-Id: Ia4a7d21179efc17d4d9af2bbc0c060e5b6512b79
2016-01-07 02:56:49 +00:00
Jenkins
4cf015d738 Merge "Support Cookies" 0.7.0 2015-11-23 00:55:50 +00:00
Jenkins
e6e4dab61d Merge "Expose Fake objects in compat" 2015-11-23 00:53:15 +00:00
Jenkins
49c0ed3f74 Merge "Change ignore-errors to ignore_errors" 2015-11-18 01:03:46 +00:00
Jamie Lennox
fe37c6cc3a Support Cookies
Cookies are treated unusually in requests. To handle them exactly as
requests does we would need to create httplib responses with headers and
pass those back. This would be a significant change that is a little
tricky. Instead use the available requests cookies handlers to merge the
cookies into the responses returned from the adapter.

Provide a way to create and preload a CookieJar that will be returned as
part of responses. We also provide the dict interface that requests
does. We don't really have a lot of choice here as these interfaces are
supported by the cookie apis and we would need to actively work around
things to remove that interface.

Change-Id: Ifc1253abc1b4004e81aa7bffad1faf32aedd0d4c
Closes-Bug: #1480835
2015-11-18 12:00:09 +11:00
Jamie Lennox
1b10e30f1e Expose Fake objects in compat
The FakeHTTPMessage and FakeHTTPResponse objects were only defined for
old versions of requests to provide compatibility. It turns out we need
these for cookie extraction in new versions as well so always define the
object and leave the old compatibility check.

Change-Id: Ifb42fd1c6b1b895b26bee59632ad0dedd78a6256
2015-11-18 12:00:06 +11:00
Jeremy Stanley
ba28c09408 Update .gitreview for new namespace
Change-Id: Ib61eb495d2fb1d466045fd061741ecf703013304
2015-10-17 22:38:27 +00:00
Monty Taylor
3293a13df4 Change ignore-errors to ignore_errors
Needed for coverage 4.0

Change-Id: If91bad253355ecb0f5cbb9b99db09d49c398e639
2015-09-21 15:27:48 +00:00
Jamie Lennox
aeb66e9046 Update docs
Update the docs to reference new features and the more recent way that
statements are written.

Change-Id: I7fc00143b9ab4366a00324aaf59d59baecf9da4a
0.6.0
2015-01-19 14:14:28 +10:00
Jenkins
9547a7b6b1 Merge "Allow to decorate class with mock" 2015-01-15 01:44:21 +00:00
Sebastian Kalinowski
1774bb11a9 Allow to decorate class with mock
Now it is possible to mock not only a function but also a class:

  class TestClass(object)

    def test_func_a(self, m):
      m.register_uri('GET', 'http://test.com', text='data')
      ...

    def test_func_b(self, m)
      m.register_uri('GET', 'http://test.com', text='data')
      ...

This new behavior mimics behavior of `patch` from `mock` library.
Added docs for this new feature.

Closes-Bug: #1404805
Change-Id: I8303dc4bc682cf12ffe86e7712b5a1c54de83efb
2014-12-22 08:37:55 +01:00
Jamie Lennox
ace78cd9c9 Use weakref to hold matcher
There is a cyclical reference here where the matcher holds a list of
requests in history and the requests hold a reference to the matcher.
Break this using a weakref so that it can be cleaned up easily.

In practice I don't see this being a problem as people will want to test
that value as part of the test where the mock is still active.

There has not been a release with this functionality so there is no
compatibility change.

Change-Id: Id1669ea40a48d09432367646a0004866947ff72b
2014-12-19 09:39:36 +10:00
Jenkins
931f2b4989 Merge "Include matcher in request history" 2014-12-18 06:05:28 +00:00
Jenkins
7b0648a921 Merge "Add called and call_count to mocker" 2014-12-16 19:35:41 +00:00
Jamie Lennox
55bbc238c6 Include matcher in request history
Include the matcher that handled this request as part of the request in
history. This will allow users to ensure that a particular history
response was generated by this mock matcher.

This is somewhat of a replacement for simply including the full response
in the history as the response object is not great to work with from a
user perspective and will be transformed between what is returned by the
adapter and what the user will see from requests.

Closes-Bug: #1402874
Change-Id: I5612f080755dbc4ce719aa961d9b29ed54a677a4
2014-12-16 14:46:54 +10:00
Jamie Lennox
755257cbdc Add called and call_count to mocker
This seems to have been an oversight to leave off. Proxy the call and
call_count variables so that they can be retrieved from the mocker.

Change-Id: I5abe9cb0b3870fd9f50a8834193d939268f11efa
2014-12-16 14:41:29 +10:00
Jenkins
3a9d7ea222 Merge "Allow specifying an exception to raise" 2014-12-16 00:57:29 +00:00
Jenkins
2412155489 Merge "Update README to use newer syntax" 2014-12-16 00:53:05 +00:00
Jamie Lennox
57f9c6a8f5 Update README to use newer syntax
Update the example code on the README to use the .get() function rather
than register_uri('GET'). This is the first thing most people see and we
want to make that look as clean as possible.

Change-Id: I87e0d40d76f70acfbe8ba9686a5ea5a6b0d73f85
2014-12-15 16:06:55 +10:00
Jamie Lennox
d8f0394293 Allow specifying an exception to raise
Make it easy to specify an exception that should be raised instead of
having to create a callback and raise it manually.

Change-Id: Iabf951e070e9ba8572f5ac14f4e09dbdd5824261
Closes-Bug: #1402496
2014-12-15 15:31:03 +10:00
Jamie Lennox
fc179b2c49 Update novaclient and keystoneclient git repo
The locations provided are no longer available. The cgit portion of the
URL has been removed.

Switch to https:// for transport.

Closes-Bug: #1402501
Change-Id: I7216259dcbae2104ee4a4dba6a451e11b14d3214
2014-12-15 15:28:41 +10:00
Jenkins
ca1c6dd58a Merge "Allow interpreting a sent request as text and json" 2014-12-02 00:41:38 +00:00
Jamie Lennox
3c4f1527e5 Add pbr to all tox environments
Doc builds are failing, apparently it's fixed by having pbr installed.
PBR really should be installed in all tox environments so just put it in
the main tox deps.

Change-Id: Iffc9a343d2953800a0afb4a92a5a6835e868994d
2014-12-02 10:01:18 +10:00
Jenkins
2349d858f3 Merge "Add docs environment to tox.ini" 2014-09-09 22:00:16 +00:00
Jenkins
0eaa4b1ddb Merge "Work toward Python 3.4 support and testing" 2014-09-09 00:04:20 +00:00
Monty Taylor
28083e5a7a Add docs environment to tox.ini
As per the governance resolution https://review.openstack.org/119875,
projects should have a docs environment in their tox.ini testing
interface. Add one.

Change-Id: Ia92b59e9b0db701b152d9c76535d7dcffdacf45d
2014-09-08 13:53:46 -07:00
Jenkins
8eb9784bf6 Merge "Add link to find bug tracker" 2014-09-06 04:23:04 +00:00
Jeremy Stanley
4b88c4bbcf Work toward Python 3.4 support and testing
Change-Id: I1d146fdb7599c57c458a910916e246bae7c44031
2014-09-03 19:09:13 +00:00
Jamie Lennox
e0a2e664ca Run tip tests against requests master as well
When running the keystoneclient and novaclient tip tests we should run
against the development branch of requests as well so that we are not
surprised by new releases upstream.

Change-Id: Iac36c91adbdf2b6fa8444d15aa8f9dee66f7e297
Related-Bug: #1363632
2014-08-31 22:15:34 +10:00
Ian Cordasco
81893873d8 Add link to find bug tracker
Change-Id: Ief5c9c555c17409638e59056ff104b917c2d0996
2014-08-29 15:58:40 -05:00
Jenkins
c6bf1637a8 Merge "Convert headers to bytes testing request_headers" 0.5.1 2014-08-28 07:09:20 +00:00
Jamie Lennox
befd86afdf Convert headers to bytes testing request_headers
In requests 1.2 and python 3 headers are bytes so we need to optionally
convert unicode text to bytes when testing that the request headers
match those being checked for.

Change-Id: I02dadc05dd5a93769da646686b938c2b26f6f267
Closes-Bug: #1361528
2014-08-28 11:03:08 +10:00
Jamie Lennox
7ba4595f95 Don't use requests.Response object directly
In requests 1.2 Responses are assumed to always have a HTTPResponse
object and it tries to extract headers from it. We solved this in the
create_response function but we didn't use it in all our tests.

Always use create_response when creating a custom matcher response.

Change-Id: I979f74a64c6f5accf1b88dcc3e5e004131945dff
Closes-Bug: #1361515
2014-08-28 10:18:24 +10:00
Jamie Lennox
968cc05105 Allow interpreting a sent request as text and json
This will make it much easier to do matching on last_request and when
doing callbacks.

Change-Id: I705f28b925afdf92c417433375d0f99d36071a6b
Closes-Bug: #1361462
2014-08-27 16:42:58 +10:00
Jenkins
79cd58d9d1 Merge "Create a tox env for requests v1.2.3" 2014-08-27 00:42:49 +00:00
Jenkins
d83b986520 Merge "Add get_all to compatibility function" 2014-08-26 19:31:14 +00:00
Jamie Lennox
e038d60b90 Create a tox env for requests v1.2.3
Requests 1.2.3 seems to be a real pain, it's right before the v2.0
cleanup and there have been a number of inconsistencies. Create a tox
environment for checking them, and we should really gate on this as
well.

Change-Id: I343b9b7124a6bfb8e1fb711a286b8a896f50fc7b
2014-08-27 04:43:54 +10:00
Jenkins
743edffba3 Merge "Don't use session.prepare_request" 2014-08-26 07:53:48 +00:00
Jamie Lennox
bdd2562d4f Add get_all to compatibility function
This is used in python 3 rather that the getheaders function that we
already stub out.

Change-Id: Ie147214a49fc744dd2ff1fc958c60547874d05d9
Closes-Bug: #1361527
2014-08-26 17:43:07 +10:00
Jamie Lennox
b0c746a04e Lowercase scheme in regexp test
This works in requests 1.1 and 2.0 but it fails in the 1.2 series. It's
not something we should be too concerned about enforcing at the
requests-mock layer so just fix up the test.

Closes-Bug: #1361497
Change-Id: I8f30262ab3177d9e3d3644c083aed6031eeba78f
2014-08-26 16:04:33 +10:00
Jamie Lennox
4f32485776 Don't use session.prepare_request
Session.prepare_request didn't exist until requests 2.0 which is newer
than our requirements specifies.

We don't really need this function, we can use the older version for
testing rather than increase our minimum required version.

Change-Id: Ia5a8c187e31b8f883e93d8086481f5e08d764bc7
Closes-Bug: #1361488
2014-08-26 15:03:59 +10:00
Jenkins
8b7387134e Merge "Remove some github specific jobs" 0.5.0 2014-08-21 08:41:32 +00:00
Jenkins
a2df6992c7 Merge "Correctly set adapter to response.connection" 2014-08-20 23:44:59 +00:00
Jamie Lennox
85d57f5678 Remove old _Context object
This was moved in a previous commit but apparently not deleted from the
old location.

Change-Id: I8efe097772a7a9fbf084ed105a2e650d0f16a19e
2014-08-20 09:34:09 +10:00
Jamie Lennox
df0e4ebd7e Correctly set adapter to response.connection
The response.connection should be the adapter that the request went
through. This is important in some situations (requests-kerberos) where
the connection is reused by the auth plugin to send additional requests.

Change-Id: I87bf996e2edbfb29eba9b4000d976a49cbf6c8cc
Closes-Bug: #1358903
2014-08-20 09:31:30 +10:00
Jamie Lennox
3cddcf2b97 Add keystoneclient and novaclient tests to tox
We want to be able to test changes in requests-mock against some of our
consumers to ensure we don't break anyone.

Change-Id: I029c25d7274e0d7638d85cbf3dc6c42aad3a5463
2014-08-18 10:37:17 +10:00
Jamie Lennox
619c37b9b0 Remove some github specific jobs
Remove Travis file, and links to travis buttons from readme.
Change homepage to the docs site, rather than personal github repo.

Change-Id: Ic6f279f9f243081c50b80a13ee1158dd181ff8cd
2014-08-07 19:52:48 +10:00
Jamie Lennox
eadbe7b1b2 Make compatible with requests 1.2
Stub out the httplib.HTTPResponse so that we can be compatible with
Requests < 2.3. We need this to be packaged in major systems that still
have older requests.

Change-Id: Ibec3cead76b7246a6987f9f3b3fef5df6bcc7bc8
2014-08-06 07:55:22 +10:00
Jamie Lennox
a6c0b3c364 Requires requests >= 2.3
There is a fix in requests v2.3 that means you don't need to use a real
httplib.Response object which the mocker relies heavily upon. That means
we need to require at least this version until we can get a fix.

Change-Id: Iff71628a33c39415ef92f04aa23bd82657bb71b5
2014-08-01 15:02:48 +10:00