aboutsummaryrefslogtreecommitdiffstats
path: root/functest/tests/unit
diff options
context:
space:
mode:
Diffstat (limited to 'functest/tests/unit')
-rw-r--r--functest/tests/unit/core/test_feature.py108
-rw-r--r--functest/tests/unit/core/test_testcase.py15
-rw-r--r--functest/tests/unit/core/test_vnf_base.py3
-rw-r--r--functest/tests/unit/features/__init__.py0
-rw-r--r--functest/tests/unit/features/test_barometer.py55
-rw-r--r--functest/tests/unit/features/test_copper.py38
-rw-r--r--functest/tests/unit/features/test_doctor.py38
-rw-r--r--functest/tests/unit/features/test_domino.py38
-rw-r--r--functest/tests/unit/features/test_netready.py39
-rw-r--r--functest/tests/unit/features/test_odl_sfc.py39
-rw-r--r--functest/tests/unit/features/test_promise.py39
-rw-r--r--functest/tests/unit/features/test_sdnvpn.py39
-rw-r--r--functest/tests/unit/features/test_security_scan.py42
13 files changed, 486 insertions, 7 deletions
diff --git a/functest/tests/unit/core/test_feature.py b/functest/tests/unit/core/test_feature.py
new file mode 100644
index 00000000..0ed178a1
--- /dev/null
+++ b/functest/tests/unit/core/test_feature.py
@@ -0,0 +1,108 @@
+#!/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 unittest
+
+import mock
+
+from functest.core import feature
+from functest.core import testcase
+from functest.utils import constants
+
+
+class FeatureInitTesting(unittest.TestCase):
+
+ logging.disable(logging.CRITICAL)
+
+ @unittest.skip("JIRA: FUNCTEST-780")
+ def test_init_with_wrong_repo(self):
+ with self.assertRaises(ValueError):
+ feature.Feature(repo='foo')
+
+ def test_init(self):
+ barometer = feature.Feature(repo='dir_repo_barometer')
+ self.assertEqual(barometer.project_name, "functest")
+ self.assertEqual(barometer.case_name, "")
+ self.assertEqual(
+ barometer.repo,
+ constants.CONST.__getattribute__('dir_repo_barometer'))
+
+
+class FeatureTesting(unittest.TestCase):
+
+ logging.disable(logging.CRITICAL)
+
+ def setUp(self):
+ self.feature = feature.Feature(repo='dir_repo_barometer')
+
+ @unittest.skip("JIRA: FUNCTEST-781")
+ def test_prepare_ko(self):
+ # pylint: disable=bad-continuation
+ with mock.patch.object(
+ self.feature, 'prepare',
+ return_value=testcase.TestCase.EX_RUN_ERROR) as mock_object:
+ self.assertEqual(self.feature.run(),
+ testcase.TestCase.EX_RUN_ERROR)
+ mock_object.assert_called_once_with()
+
+ @unittest.skip("JIRA: FUNCTEST-781")
+ def test_prepare_exc(self):
+ with mock.patch.object(self.feature, 'prepare',
+ side_effect=Exception) as mock_object:
+ self.assertEqual(self.feature.run(),
+ testcase.TestCase.EX_RUN_ERROR)
+ mock_object.assert_called_once_with()
+
+ @unittest.skip("JIRA: FUNCTEST-781")
+ def test_post_ko(self):
+ # pylint: disable=bad-continuation
+ with mock.patch.object(
+ self.feature, 'post',
+ return_value=testcase.TestCase.EX_RUN_ERROR) as mock_object:
+ self.assertEqual(self.feature.run(),
+ testcase.TestCase.EX_RUN_ERROR)
+ mock_object.assert_called_once_with()
+
+ @unittest.skip("JIRA: FUNCTEST-781")
+ def test_post_exc(self):
+ with mock.patch.object(self.feature, 'post',
+ side_effect=Exception) as mock_object:
+ self.assertEqual(self.feature.run(),
+ testcase.TestCase.EX_RUN_ERROR)
+ mock_object.assert_called_once_with()
+
+ @unittest.skip("JIRA: FUNCTEST-778")
+ def test_execute_ko(self):
+ with mock.patch.object(self.feature, 'execute',
+ return_value=1) as mock_object:
+ self.assertEqual(self.feature.run(),
+ testcase.TestCase.EX_RUN_ERROR)
+ mock_object.assert_called_once_with()
+
+ @unittest.skip("JIRA: FUNCTEST-778")
+ def test_execute_exc(self):
+ with mock.patch.object(self.feature, 'execute',
+ side_effect=Exception) as mock_object:
+ self.assertEqual(self.feature.run(),
+ testcase.TestCase.EX_RUN_ERROR)
+ mock_object.assert_called_once_with()
+
+ def test_run(self):
+ with mock.patch.object(self.feature, 'execute',
+ return_value=0) as mock_object:
+ self.assertEqual(self.feature.run(),
+ testcase.TestCase.EX_OK)
+ mock_object.assert_called_once_with()
+
+
+if __name__ == "__main__":
+ unittest.main(verbosity=2)
diff --git a/functest/tests/unit/core/test_testcase.py b/functest/tests/unit/core/test_testcase.py
index 32104194..5ff41cd6 100644
--- a/functest/tests/unit/core/test_testcase.py
+++ b/functest/tests/unit/core/test_testcase.py
@@ -26,10 +26,11 @@ class TestCaseTesting(unittest.TestCase):
logging.disable(logging.CRITICAL)
+ _case_name = "base"
+
def setUp(self):
- self.test = testcase.TestCase()
+ self.test = testcase.TestCase(case_name=self._case_name)
self.test.project = "functest"
- self.test.case_name = "base"
self.test.start_time = "1"
self.test.stop_time = "2"
self.test.criteria = "PASS"
@@ -46,6 +47,10 @@ class TestCaseTesting(unittest.TestCase):
testcase.TestCase.EX_PUSH_TO_DB_ERROR)
mock_function.assert_not_called()
+ def test_missing_project_name(self):
+ self.test.project_name = None
+ self._test_missing_attribute()
+
def test_missing_case_name(self):
self.test.case_name = None
self._test_missing_attribute()
@@ -69,7 +74,7 @@ class TestCaseTesting(unittest.TestCase):
self.assertEqual(self.test.push_to_db(),
testcase.TestCase.EX_OK)
mock_function.assert_called_once_with(
- self.test.project, self.test.case_name, self.test.start_time,
+ self.test.project, self._case_name, self.test.start_time,
self.test.stop_time, self.test.criteria, self.test.details)
@mock.patch('functest.utils.functest_utils.push_results_to_db',
@@ -78,7 +83,7 @@ class TestCaseTesting(unittest.TestCase):
self.assertEqual(self.test.push_to_db(),
testcase.TestCase.EX_PUSH_TO_DB_ERROR)
mock_function.assert_called_once_with(
- self.test.project, self.test.case_name, self.test.start_time,
+ self.test.project, self._case_name, self.test.start_time,
self.test.stop_time, self.test.criteria, self.test.details)
@mock.patch('functest.utils.functest_utils.push_results_to_db',
@@ -87,7 +92,7 @@ class TestCaseTesting(unittest.TestCase):
self.assertEqual(self.test.push_to_db(),
testcase.TestCase.EX_OK)
mock_function.assert_called_once_with(
- self.test.project, self.test.case_name, self.test.start_time,
+ self.test.project, self._case_name, self.test.start_time,
self.test.stop_time, self.test.criteria, self.test.details)
def test_check_criteria_missing(self):
diff --git a/functest/tests/unit/core/test_vnf_base.py b/functest/tests/unit/core/test_vnf_base.py
index 1680f03f..96706040 100644
--- a/functest/tests/unit/core/test_vnf_base.py
+++ b/functest/tests/unit/core/test_vnf_base.py
@@ -19,9 +19,8 @@ class VnfBaseTesting(unittest.TestCase):
def setUp(self):
self.test = vnf_base.VnfOnBoardingBase(project='functest',
- case='aaa')
+ case_name='aaa')
self.test.project = "functest"
- self.test.case_name = "aaa"
self.test.start_time = "1"
self.test.stop_time = "5"
self.test.criteria = ""
diff --git a/functest/tests/unit/features/__init__.py b/functest/tests/unit/features/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /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 00000000..62f2e0d6
--- /dev/null
+++ b/functest/tests/unit/features/test_barometer.py
@@ -0,0 +1,55 @@
+#!/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(
+ case_name="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/functest/tests/unit/features/test_copper.py b/functest/tests/unit/features/test_copper.py
new file mode 100644
index 00000000..b6d187f7
--- /dev/null
+++ b/functest/tests/unit/features/test_copper.py
@@ -0,0 +1,38 @@
+#!/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 unittest
+
+from functest.opnfv_tests.features import copper
+from functest.utils import constants
+
+
+class CopperTesting(unittest.TestCase):
+
+ logging.disable(logging.CRITICAL)
+
+ def setUp(self):
+ self.copper = copper.Copper(case_name="copper-notification")
+
+ def test_init(self):
+ self.assertEqual(self.copper.project_name, "copper")
+ self.assertEqual(self.copper.case_name, "copper-notification")
+ self.assertEqual(
+ self.copper.repo,
+ constants.CONST.__getattribute__("dir_repo_copper"))
+ self.assertEqual(
+ self.copper.cmd,
+ "cd {}/tests && bash run.sh && cd -".format(self.copper.repo))
+
+
+if __name__ == "__main__":
+ unittest.main(verbosity=2)
diff --git a/functest/tests/unit/features/test_doctor.py b/functest/tests/unit/features/test_doctor.py
new file mode 100644
index 00000000..36bac44f
--- /dev/null
+++ b/functest/tests/unit/features/test_doctor.py
@@ -0,0 +1,38 @@
+#!/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 unittest
+
+from functest.opnfv_tests.features import doctor
+from functest.utils import constants
+
+
+class DoctorTesting(unittest.TestCase):
+
+ logging.disable(logging.CRITICAL)
+
+ def setUp(self):
+ self.doctor = doctor.Doctor(case_name="doctor-notification")
+
+ def test_init(self):
+ self.assertEqual(self.doctor.project_name, "doctor")
+ self.assertEqual(self.doctor.case_name, "doctor-notification")
+ self.assertEqual(
+ self.doctor.repo,
+ constants.CONST.__getattribute__("dir_repo_doctor"))
+ self.assertEqual(
+ self.doctor.cmd,
+ 'cd {}/tests && ./run.sh'.format(self.doctor.repo))
+
+
+if __name__ == "__main__":
+ unittest.main(verbosity=2)
diff --git a/functest/tests/unit/features/test_domino.py b/functest/tests/unit/features/test_domino.py
new file mode 100644
index 00000000..c0bfd14b
--- /dev/null
+++ b/functest/tests/unit/features/test_domino.py
@@ -0,0 +1,38 @@
+#!/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 unittest
+
+from functest.opnfv_tests.features import domino
+from functest.utils import constants
+
+
+class DominoTesting(unittest.TestCase):
+
+ logging.disable(logging.CRITICAL)
+
+ def setUp(self):
+ self.domino = domino.Domino(case_name="domino-multinode")
+
+ def test_init(self):
+ self.assertEqual(self.domino.project_name, "domino")
+ self.assertEqual(self.domino.case_name, "domino-multinode")
+ self.assertEqual(
+ self.domino.repo,
+ constants.CONST.__getattribute__("dir_repo_domino"))
+ self.assertEqual(
+ self.domino.cmd,
+ 'cd {} && ./tests/run_multinode.sh'.format(self.domino.repo))
+
+
+if __name__ == "__main__":
+ unittest.main(verbosity=2)
diff --git a/functest/tests/unit/features/test_netready.py b/functest/tests/unit/features/test_netready.py
new file mode 100644
index 00000000..47be4203
--- /dev/null
+++ b/functest/tests/unit/features/test_netready.py
@@ -0,0 +1,39 @@
+#!/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 unittest
+
+from functest.opnfv_tests.features import netready
+from functest.utils import constants
+
+
+class NetreadyTesting(unittest.TestCase):
+
+ logging.disable(logging.CRITICAL)
+
+ def setUp(self):
+ self.netready = netready.GluonVping(case_name="gluon_vping")
+
+ def test_init(self):
+ self.assertEqual(self.netready.project_name, "netready")
+ self.assertEqual(self.netready.case_name, "gluon_vping")
+ self.assertEqual(
+ self.netready.repo,
+ constants.CONST.__getattribute__("dir_repo_netready"))
+ self.assertEqual(
+ self.netready.cmd,
+ 'cd {}/test/functest && python ./gluon-test-suite.py'.format(
+ self.netready.repo))
+
+
+if __name__ == "__main__":
+ unittest.main(verbosity=2)
diff --git a/functest/tests/unit/features/test_odl_sfc.py b/functest/tests/unit/features/test_odl_sfc.py
new file mode 100644
index 00000000..dcdcdff6
--- /dev/null
+++ b/functest/tests/unit/features/test_odl_sfc.py
@@ -0,0 +1,39 @@
+#!/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 unittest
+
+from functest.opnfv_tests.features import odl_sfc
+from functest.utils import constants
+
+
+class OpenDaylightSFCTesting(unittest.TestCase):
+
+ logging.disable(logging.CRITICAL)
+
+ def setUp(self):
+ self.odl_sfc = odl_sfc.OpenDaylightSFC(case_name="functest-odl-sfc")
+
+ def test_init(self):
+ self.assertEqual(self.odl_sfc.project_name, "sfc")
+ self.assertEqual(self.odl_sfc.case_name, "functest-odl-sfc")
+ self.assertEqual(
+ self.odl_sfc.repo,
+ constants.CONST.__getattribute__("dir_repo_sfc"))
+ dir_sfc_functest = '{}/sfc/tests/functest'.format(self.odl_sfc.repo)
+ self.assertEqual(
+ self.odl_sfc.cmd,
+ 'cd {} && python ./run_tests.py'.format(dir_sfc_functest))
+
+
+if __name__ == "__main__":
+ unittest.main(verbosity=2)
diff --git a/functest/tests/unit/features/test_promise.py b/functest/tests/unit/features/test_promise.py
new file mode 100644
index 00000000..29b4d4ec
--- /dev/null
+++ b/functest/tests/unit/features/test_promise.py
@@ -0,0 +1,39 @@
+#!/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 unittest
+
+from functest.opnfv_tests.features import promise
+from functest.utils import constants
+
+
+class PromiseTesting(unittest.TestCase):
+
+ logging.disable(logging.CRITICAL)
+
+ def setUp(self):
+ self.promise = promise.Promise(case_name="promise")
+
+ def test_init(self):
+ self.assertEqual(self.promise.project_name, "promise")
+ self.assertEqual(self.promise.case_name, "promise")
+ self.assertEqual(
+ self.promise.repo,
+ constants.CONST.__getattribute__("dir_repo_promise"))
+ self.assertEqual(
+ self.promise.cmd,
+ 'cd {}/promise/test/functest && python ./run_tests.py'.format(
+ self.promise.repo))
+
+
+if __name__ == "__main__":
+ unittest.main(verbosity=2)
diff --git a/functest/tests/unit/features/test_sdnvpn.py b/functest/tests/unit/features/test_sdnvpn.py
new file mode 100644
index 00000000..8fa43fc4
--- /dev/null
+++ b/functest/tests/unit/features/test_sdnvpn.py
@@ -0,0 +1,39 @@
+#!/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 unittest
+
+from functest.opnfv_tests.features import sdnvpn
+from functest.utils import constants
+
+
+class SdnVpnTesting(unittest.TestCase):
+
+ logging.disable(logging.CRITICAL)
+
+ def setUp(self):
+ self.sdnvpn = sdnvpn.SdnVpnTests(case_name="bgpvpn")
+
+ def test_init(self):
+ self.assertEqual(self.sdnvpn.project_name, "sdnvpn")
+ self.assertEqual(self.sdnvpn.case_name, "bgpvpn")
+ self.assertEqual(
+ self.sdnvpn.repo,
+ constants.CONST.__getattribute__("dir_repo_sdnvpn"))
+ self.assertEqual(
+ self.sdnvpn.cmd,
+ 'cd {}/sdnvpn/test/functest && python ./run_tests.py'.format(
+ self.sdnvpn.repo))
+
+
+if __name__ == "__main__":
+ unittest.main(verbosity=2)
diff --git a/functest/tests/unit/features/test_security_scan.py b/functest/tests/unit/features/test_security_scan.py
new file mode 100644
index 00000000..f0e40159
--- /dev/null
+++ b/functest/tests/unit/features/test_security_scan.py
@@ -0,0 +1,42 @@
+#!/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 unittest
+
+from functest.opnfv_tests.features import security_scan
+from functest.utils import constants
+
+
+class SecurityScanTesting(unittest.TestCase):
+
+ logging.disable(logging.CRITICAL)
+
+ def setUp(self):
+ self.sscan = security_scan.SecurityScan(case_name="security_scan")
+
+ def test_init(self):
+ self.assertEqual(self.sscan.project_name, "securityscanning")
+ self.assertEqual(self.sscan.case_name, "security_scan")
+ self.assertEqual(
+ self.sscan.repo,
+ constants.CONST.__getattribute__("dir_repo_securityscan"))
+ self.assertEqual(
+ self.sscan.cmd, (
+ '. {0}/stackrc && cd {1} && '
+ 'python security_scan.py --config config.ini && '
+ 'cd -'.format(
+ constants.CONST.__getattribute__("dir_functest_conf"),
+ self.sscan.repo)))
+
+
+if __name__ == "__main__":
+ unittest.main(verbosity=2)