Skip to content

Commit bdce2bf

Browse files
authored
Merge pull request #42 from ShipChain/mocket
Replace httpretty with responses
2 parents c825659 + f0f7c5d commit bdce2bf

File tree

4 files changed

+242
-188
lines changed

4 files changed

+242
-188
lines changed

README.md

+8-15
Original file line numberDiff line numberDiff line change
@@ -192,28 +192,21 @@ This will automatically add the `json_asserter` and set it as a class attribute
192192
This allows you to just call `self.json_asserter`, allowing for cleaner unit tests imports.
193193

194194

195-
### HTTPrettyAsserter Usage
195+
### ResponsesAsserter Usage
196196

197197
When mocking calls, this can help in ensuring all calls, and only those, were made as expected, with the desired parameters.
198-
In order to use, simply import the HTTPrettyAsserter from test_utils and use it in place of the usual httpretty:
199-
```python
200-
@pytest.yield_fixture
201-
def modified_http_pretty():
202-
HTTPrettyAsserter.enable(allow_net_connect=False)
203-
yield HTTPrettyAsserter
204-
HTTPrettyAsserter.disable()
205-
```
198+
In order to use, simply import the `modified_responses` fixture from test_utils.
206199

207-
Then, you just need to register the uris for the calls you want to mock, and ensure that it is returned in the mocking:
200+
Then, you just need to register the uris for the calls you want to mock:
208201
```python
209202
@pytest.fixture
210-
def http_pretty_list_mocking(modified_http_pretty):
211-
modified_http_pretty.register_uri(modified_http_pretty.POST, 'http://google.com/path', status=status.HTTP_200_OK)
212-
modified_http_pretty.register_uri(modified_http_pretty.POST, 'http://google.com/other_path',
203+
def responses_list_mocking(modified_responses):
204+
modified_responses.register_uri(modified_responses.POST, 'http://google.com/path', status=status.HTTP_200_OK)
205+
modified_responses.register_uri(modified_responses.POST, 'http://google.com/other_path',
213206
status=status.HTTP_200_OK)
214-
modified_http_pretty.register_uri(modified_http_pretty.POST, 'http://bing.com/bing_path',
207+
modified_responses.register_uri(modified_responses.POST, 'http://bing.com/bing_path',
215208
status=status.HTTP_200_OK)
216-
return modified_http_pretty
209+
return modified_responses
217210
```
218211

219212
In a test that you want to check the calls on, you simply need to use the mocking fixture and call `.assert_calls(assertions)` on the fixture.

0 commit comments

Comments
 (0)