3 # Copyright (c) 2017 Orange and others.
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
10 # pylint: disable=missing-docstring
18 from functest.core import testcase
19 with mock.patch('functest.utils.functest_utils.get_parameter_from_yaml'):
20 from functest.opnfv_tests.features import barometer
23 class BarometerTesting(unittest.TestCase):
25 _case_name = "barometercollectd"
26 _project_name = "barometer"
29 self.barometer = barometer.BarometerCollectd(
30 case_name=self._case_name, project_name=self._project_name)
33 self.assertEqual(self.barometer.project_name, self._project_name)
34 self.assertEqual(self.barometer.case_name, self._case_name)
36 def test_run_ko(self):
37 sys.modules['baro_tests'].collectd.main = mock.Mock(return_value=1)
38 self.assertEqual(self.barometer.run(),
39 testcase.TestCase.EX_RUN_ERROR)
42 sys.modules['baro_tests'].collectd.main = mock.Mock(return_value=0)
43 self.assertEqual(self.barometer.run(), testcase.TestCase.EX_OK)
46 if __name__ == "__main__":
47 logging.disable(logging.CRITICAL)
48 unittest.main(verbosity=2)