MCPcopy Create free account
hub / github.com/apache/mesos / test_resource_post_json

Function test_resource_post_json

src/python/lib/tests/test_http.py:329–351  ·  view source on GitHub ↗
(mock_mesos_http_request)

Source from the content-addressed store, hash-verified

327
328
329def 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'}

Callers

nothing calls this directly

Calls 2

post_jsonMethod · 0.95
callMethod · 0.45

Tested by

no test coverage detected