• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2015 The Chromium OS Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5import logging
6import unittest
7
8import common
9from autotest_lib.client.cros.cellular.mbim_compliance import mbim_errors
10
11
12class MBIMComplianceAssertionErrorTestCase(unittest.TestCase):
13    """ Test MBIMComplianceAsertionError construction. """
14
15    def test_correct_assertion_code(self):
16        """ Constructs an error with a valid assertion id. """
17        self.assertRaises(
18                mbim_errors.MBIMComplianceAssertionError,
19                mbim_errors.log_and_raise,
20                mbim_errors.MBIMComplianceAssertionError,
21                'mbim1.0:3.2.1#1')
22
23
24    def test_correct_assertion_code_and_error_string(self):
25        """ Constructs an error with a valid assertion id and extra string. """
26        self.assertRaises(
27                mbim_errors.MBIMComplianceAssertionError,
28                mbim_errors.log_and_raise,
29                mbim_errors.MBIMComplianceAssertionError,
30                'mbim1.0:3.2.1#1',
31                'Some error')
32
33
34    def test_incorrect_assertion_code(self):
35        """ Constructs an error with and invalid assertion id. """
36        self.assertRaises(
37                mbim_errors.MBIMComplianceFrameworkError,
38                mbim_errors.log_and_raise,
39                mbim_errors.MBIMComplianceAssertionError,
40                'wrong_id_obviously')
41
42
43    def test_generic_assertion_error(self):
44        """ Constructs a generic error. """
45        self.assertRaises(
46                mbim_errors.MBIMComplianceGenericAssertionError,
47                mbim_errors.log_and_raise,
48                mbim_errors.MBIMComplianceGenericAssertionError,
49                'some generic error')
50
51
52if __name__ == '__main__':
53    logging.basicConfig(level=logging.DEBUG)
54    unittest.main()
55