1 ##############################################################################
2 # Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9 from __future__ import absolute_import
14 from oslo_serialization import jsonutils
16 from yardstick.common import httpClient
19 class HttpClientTestCase(unittest.TestCase):
21 @mock.patch('yardstick.common.httpClient.requests')
22 def test_post(self, mock_requests):
23 url = 'http://localhost:5000/hello'
24 data = {'hello': 'world'}
25 headers = {'Content-Type': 'application/json'}
26 httpClient.HttpClient().post(url, data)
27 mock_requests.post.assert_called_with(
28 url, data=jsonutils.dump_as_bytes(data),
31 @mock.patch('yardstick.common.httpClient.requests')
32 def test_get(self, mock_requests):
33 url = 'http://localhost:5000/hello'
34 httpClient.HttpClient().get(url)
35 mock_requests.get.assert_called_with(url)