summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCédric Ollivier <cedric.ollivier@orange.com>2017-04-01 13:49:27 +0200
committerCédric Ollivier <cedric.ollivier@orange.com>2017-04-04 15:16:52 +0200
commit98edab949da9fcce193acc9b66546b7b2fd77d7c (patch)
treea2ebd669adc73254a9d077fb2431c406433f9d15
parentd06d840c00d4e3b58b826447e17035469e967357 (diff)
Add unit tests for barometer
2 tests are skipped to allow merging [1] [1] https://jira.opnfv.org/browse/FUNCTEST-777 Change-Id: Ida376a03266489e252f7ef8de1ff40f1474c500a Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
-rw-r--r--functest/tests/unit/features/__init__.py0
-rw-r--r--functest/tests/unit/features/test_barometer.py54
-rwxr-xr-xrun_unit_tests.sh1
3 files changed, 55 insertions, 0 deletions
diff --git a/functest/tests/unit/features/__init__.py b/functest/tests/unit/features/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/functest/tests/unit/features/__init__.py
diff --git a/functest/tests/unit/features/test_barometer.py b/functest/tests/unit/features/test_barometer.py
new file mode 100644
index 000000000..6c68019dc
--- /dev/null
+++ b/functest/tests/unit/features/test_barometer.py
@@ -0,0 +1,54 @@
+#!/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
+from functest.utils import constants
+
+
+class BarometerTesting(unittest.TestCase):
+
+ logging.disable(logging.CRITICAL)
+
+ def setUp(self):
+ self.barometer = barometer.BarometerCollectd()
+
+ def test_init(self):
+ self.assertEqual(self.barometer.project_name, "barometer")
+ self.assertEqual(self.barometer.case_name, "barometercollectd")
+ self.assertEqual(
+ self.barometer.repo,
+ constants.CONST.__getattribute__('dir_repo_barometer'))
+
+ @unittest.skip("JIRA: FUNCTEST-777")
+ def test_execute_ko(self):
+ # It must be skipped to allow merging
+ sys.modules['baro_tests'].collectd.main = mock.Mock(return_value=1)
+ self.assertEqual(self.barometer.execute(),
+ testcase.TestCase.EX_RUN_ERROR)
+
+ @unittest.skip("JIRA: FUNCTEST-777")
+ def test_execute(self):
+ # It must be skipped to allow merging
+ sys.modules['baro_tests'].collectd.main = mock.Mock(return_value=0)
+ self.assertEqual(self.barometer.execute(), testcase.TestCase.EX_OK)
+
+
+if __name__ == "__main__":
+ unittest.main(verbosity=2)
diff --git a/run_unit_tests.sh b/run_unit_tests.sh
index 3de9b36f9..0ed1f7b3b 100755
--- a/run_unit_tests.sh
+++ b/run_unit_tests.sh
@@ -44,6 +44,7 @@ nosetests --with-xunit \
--cover-package=functest.opnfv_tests.sdn.odl.odl \
--cover-package=functest.opnfv_tests.vnf.ims \
--cover-package=functest.utils \
+ --cover-package=functest.opnfv_tests.features \
--cover-package=functest.opnfv_tests.openstack \
--cover-xml \
--cover-html \