Re-Enable Promise testcases
[functest.git] / functest / tests / unit / features / test_barometer.py
1 #!/usr/bin/env python
2
3 # Copyright (c) 2017 Orange and others.
4 #
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9
10 # pylint: disable=missing-docstring
11
12 import logging
13 import sys
14 import unittest
15
16 import mock
17
18 from functest.core import testcase
19 sys.modules['baro_tests'] = mock.Mock()  # noqa
20 # pylint: disable=wrong-import-position
21 from functest.opnfv_tests.features import barometer
22
23
24 class BarometerTesting(unittest.TestCase):
25
26     logging.disable(logging.CRITICAL)
27
28     _case_name = "barometercollectd"
29     _project_name = "barometer"
30
31     def setUp(self):
32         self.barometer = barometer.BarometerCollectd(
33             case_name=self._case_name, project_name=self._project_name)
34
35     def test_init(self):
36         self.assertEqual(self.barometer.project_name, self._project_name)
37         self.assertEqual(self.barometer.case_name, self._case_name)
38
39     def test_run_ko(self):
40         sys.modules['baro_tests'].collectd.main = mock.Mock(return_value=1)
41         self.assertEqual(self.barometer.run(),
42                          testcase.TestCase.EX_RUN_ERROR)
43
44     def test_run(self):
45         sys.modules['baro_tests'].collectd.main = mock.Mock(return_value=0)
46         self.assertEqual(self.barometer.run(), testcase.TestCase.EX_OK)
47
48
49 if __name__ == "__main__":
50     unittest.main(verbosity=2)