blob: ba1b69acb2fece4010e6d646c3a1670b74ff45cb [file] [log] [blame]
Treehugger Robotf08cd812018-06-19 01:39:19 +00001#!/usr/bin/env python3
2#
3# Copyright 2018 - The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16import unittest
17
18from acts import error
19
20
21class ActsErrorTest(unittest.TestCase):
Mark De Ruyter8e627fe2018-07-11 16:10:20 -070022
23 def test_assert_key_pulled_from_acts_error_code(self):
Treehugger Robotf08cd812018-06-19 01:39:19 +000024 e = error.ActsError()
25 self.assertEqual(e.error_code, 100)
Mark De Ruyter8e627fe2018-07-11 16:10:20 -070026
27 def test_assert_description_pulled_from_docstring(self):
28 e = error.ActsError()
Treehugger Robotf08cd812018-06-19 01:39:19 +000029 self.assertEqual(e.message, 'Base Acts Error')
Mark De Ruyter8e627fe2018-07-11 16:10:20 -070030
31 def test_error_without_args(self):
32 e = error.ActsError()
Mark De Ruyter185960b2018-07-30 12:50:00 -070033 self.assertNotIn('details', e.extra)
Treehugger Robotf08cd812018-06-19 01:39:19 +000034
35 def test_error_with_args(self):
Mark De Ruyter185960b2018-07-30 12:50:00 -070036 args = ('hello', )
Mark De Ruyter8e627fe2018-07-11 16:10:20 -070037 e = error.ActsError(*args)
38 self.assertEqual(e.extra['details'], args)
39
40 def test_error_with_kwargs(self):
41 e = error.ActsError(key='value')
42 self.assertTrue('key' in e.extra.keys())
43 self.assertTrue('value' in e.extra['key'])
Treehugger Robotf08cd812018-06-19 01:39:19 +000044
45
46if __name__ == '__main__':
47 unittest.main()