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
17 class TestTestCase(unittest.TestCase):
19 @mock.patch('api.views.request')
20 def test_post(self, mock_request):
21 mock_request.json.get.side_effect = ['hello', {}]
23 result = json.loads(Test().post())
25 self.assertEqual('error', result['status'])
28 class ResultTestCase(unittest.TestCase):
30 @mock.patch('api.views.request')
31 def test_get(self, mock_request):
32 mock_request.args.get.return_value = 'hello'
35 result = json.loads(Result().get())
37 self.assertEqual('error', result['status'])
44 if __name__ == '__main__':