7 Commits

Author SHA1 Message Date
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
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
Jamie Lennox
4ae5f15568 Add a mock() function
This is the same as the Mocker() however it looks more correct to do
@requests_mock.mock() rather than @requests_mock.Mocker().

Ideally mock() would be the decorator and Mocker() the context manager
but it doesn't really matter.
2014-07-30 06:40:10 +10:00
Jamie Lennox
96fbd5a0ee Export symbols for HTTP methods
This shouldn't be considered the way to use these methods, using the
strings are fine, but in certain places people don't like using strings
everywhere and so we should have the constants available for them.
2014-07-30 06:28:33 +10:00
Jamie Lennox
33474a296e Http Methods handling to look more like requests
Allow users to specify methods via the same HTTP method based format
that requests does. It makes them look more synchronous.
2014-07-10 14:24:50 +10:00
Jamie Lennox
24e7d43a16 Allow custom matchers
Allow users to specify there own matchers. A matcher should take a
request and return a response or None.
2014-07-01 12:50:56 +10:00
Jamie Lennox
833ee180c3 Create the Mocker
A standard means of mock loading the adapter. Because we have this move
fixtures stuff into contrib.

Add some documentation for all this.
2014-06-23 16:03:40 +10:00