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