Merge "Create API and command to create a influxDB container"
[yardstick.git] / tests / unit / common / test_httpClient.py
1 ##############################################################################
2 # Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
3 #
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 import unittest
10 import mock
11 import json
12
13 from yardstick.common import httpClient
14
15
16 class HttpClientTestCase(unittest.TestCase):
17
18     @mock.patch('yardstick.common.httpClient.requests')
19     def test_post(self, mock_requests):
20         url = 'http://localhost:5000/hello'
21         data = {'hello': 'world'}
22         headers = {'Content-Type': 'application/json'}
23         httpClient.HttpClient().post(url, data)
24         mock_requests.post.assert_called_with(url, data=json.dumps(data),
25                                               headers=headers)
26
27
28 def main():
29     unittest.main()
30
31
32 if __name__ == '__main__':
33     main()