Decoupling prepare_env.sh and load_images.sh
[yardstick.git] / tests / unit / api / test_views.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 api.views import Test
14 from api.views import Result
15
16
17 class TestTestCase(unittest.TestCase):
18
19     @mock.patch('api.views.request')
20     def test_post(self, mock_request):
21         mock_request.json.get.side_effect = ['hello', {}]
22
23         result = json.loads(Test().post())
24
25         self.assertEqual('error', result['status'])
26
27
28 class ResultTestCase(unittest.TestCase):
29
30     @mock.patch('api.views.request')
31     def test_get(self, mock_request):
32         mock_request.args.get.return_value = 'hello'
33
34         print Result().get()
35         result = json.loads(Result().get())
36
37         self.assertEqual('error', result['status'])
38
39
40 def main():
41     unittest.main()
42
43
44 if __name__ == '__main__':
45     main()