@@ -192,28 +192,21 @@ This will automatically add the `json_asserter` and set it as a class attribute
192
192
This allows you to just call ` self.json_asserter ` , allowing for cleaner unit tests imports.
193
193
194
194
195
- ### HTTPrettyAsserter Usage
195
+ ### ResponsesAsserter Usage
196
196
197
197
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.
206
199
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:
208
201
``` python
209
202
@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' ,
213
206
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' ,
215
208
status = status.HTTP_200_OK )
216
- return modified_http_pretty
209
+ return modified_responses
217
210
```
218
211
219
212
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