| 327 | |
| 328 | |
| 329 | def test_resource_post_json(mock_mesos_http_request): |
| 330 | mock_mesos_http_request.return_value = mock.Mock( |
| 331 | status_code=200, |
| 332 | text=ujson.dumps({'hello': 'world'}), |
| 333 | ) |
| 334 | mock_auth = mock.Mock() |
| 335 | resource = http.Resource('http://some.domain/some/prefix', |
| 336 | default_timeout=100, |
| 337 | default_auth=mock_auth, |
| 338 | default_max_attempts=1, |
| 339 | default_use_gzip_encoding=True) |
| 340 | ret = resource.post_json(payload={'somekey': 'someval'}) |
| 341 | assert mock_mesos_http_request.mock_calls == [ |
| 342 | mock.call(json={'somekey': 'someval'}, |
| 343 | method='POST', |
| 344 | url='http://some.domain/some/prefix', |
| 345 | auth=mock_auth, |
| 346 | headers={'Accept-Encoding': 'gzip', |
| 347 | 'Accept': 'application/json'}, |
| 348 | params=None, |
| 349 | timeout=100) |
| 350 | ] |
| 351 | assert ret == {'hello': 'world'} |