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 ##############################################################################
13 from api.views import Test
14 from api.views import Result
15 from api.views import Env
18 class TestTestCase(unittest.TestCase):
20 @mock.patch('api.views.request')
21 def test_post(self, mock_request):
22 mock_request.json.get.side_effect = ['hello', {}]
24 result = json.loads(Test().post())
26 self.assertEqual('error', result['status'])
29 class ResultTestCase(unittest.TestCase):
31 @mock.patch('api.views.request')
32 def test_get(self, mock_request):
33 mock_request.args.get.return_value = 'hello'
36 result = json.loads(Result().get())
38 self.assertEqual('error', result['status'])
41 class EnvTestCase(unittest.TestCase):
43 @mock.patch('api.views.request')
44 def test_post(self, mock_request):
45 mock_request.json.get.side_effect = ['hello', {}]
47 result = json.loads(Env().post())
49 self.assertEqual('error', result['status'])
56 if __name__ == '__main__':