async def test_json_parser(mocker): headers = HttpHeaders() _add_header(headers, 'Content-Type', 'application/json') # python<=3.7 compatible mock async def mocked(*args, **kwargs): mock = mocker.MagicMock() mock(*args, **kwargs) return mock mocker.patch('aiosonic.HTTPClient.request', new=mocked) instance = HTTPClient() res = await instance.post('foo', json=[]) res.assert_called_once_with(instance, 'foo', 'POST', headers, None, '[]', False, verify=True, ssl=None, follow=False, timeouts=None, http2=False)
def test_add_header_list_replace(): """Test add header method into list with replace True.""" headers = [] _add_header(headers, 'foo', 'bar') _add_header(headers, 'foo', 'baz', True) assert headers == [('foo', 'baz')]
def test_add_header_list(): """Test add header method into list.""" headers = [] _add_header(headers, 'content-type', 'application/json') assert headers == [('content-type', 'application/json')]
def test_add_header(): """Test add header method.""" headers = HttpHeaders() _add_header(headers, 'content-type', 'application/json') assert headers == {'content-type': 'application/json'}