aboutsummaryrefslogtreecommitdiffstats
path: root/functest/tests
diff options
context:
space:
mode:
Diffstat (limited to 'functest/tests')
-rw-r--r--functest/tests/unit/core/test_feature.py24
-rw-r--r--functest/tests/unit/features/test_copper.py39
-rw-r--r--functest/tests/unit/features/test_doctor.py40
-rw-r--r--functest/tests/unit/features/test_domino.py40
-rw-r--r--functest/tests/unit/features/test_netready.py40
-rw-r--r--functest/tests/unit/features/test_odl_sfc.py42
-rw-r--r--functest/tests/unit/features/test_promise.py41
-rw-r--r--functest/tests/unit/features/test_sdnvpn.py40
-rw-r--r--functest/tests/unit/features/test_security_scan.py44
-rw-r--r--functest/tests/unit/vnf/rnc/test_parser.py40
10 files changed, 19 insertions, 371 deletions
diff --git a/functest/tests/unit/core/test_feature.py b/functest/tests/unit/core/test_feature.py
index ac4b04c4..bd7197f0 100644
--- a/functest/tests/unit/core/test_feature.py
+++ b/functest/tests/unit/core/test_feature.py
@@ -17,6 +17,8 @@ import mock
from functest.core import feature
from functest.core import testcase
+# logging must be disabled else it calls time.time()
+# what will break these unit tests.
logging.disable(logging.CRITICAL)
@@ -27,10 +29,11 @@ class FeatureTestingBase(unittest.TestCase):
_repo = "dir_repo_copper"
_cmd = "cd /home/opnfv/repos/foo/tests && bash run.sh && cd -"
_output_file = '/home/opnfv/functest/results/bar.log'
+ feature = None
@mock.patch('time.time', side_effect=[1, 2])
def _test_run(self, status, mock_method=None):
- self.assertEqual(self.feature.run(), status)
+ self.assertEqual(self.feature.run(cmd=self._cmd), status)
if status == testcase.TestCase.EX_OK:
self.assertEqual(self.feature.criteria, 'PASS')
else:
@@ -44,8 +47,15 @@ class FeatureTesting(FeatureTestingBase):
def setUp(self):
self.feature = feature.Feature(
- project_name=self._project_name, case_name=self._case_name,
- cmd=self._cmd)
+ project_name=self._project_name, case_name=self._case_name)
+
+ def test_run_exc(self):
+ # pylint: disable=bad-continuation
+ with mock.patch.object(
+ self.feature, 'execute',
+ side_effect=Exception) as mock_method:
+ self._test_run(testcase.TestCase.EX_RUN_ERROR)
+ mock_method.assert_called_once_with(cmd=self._cmd)
def test_run(self):
self._test_run(testcase.TestCase.EX_RUN_ERROR)
@@ -55,8 +65,12 @@ class BashFeatureTesting(FeatureTestingBase):
def setUp(self):
self.feature = feature.BashFeature(
- project_name=self._project_name, case_name=self._case_name,
- cmd=self._cmd)
+ project_name=self._project_name, case_name=self._case_name)
+
+ @mock.patch("functest.utils.functest_utils.execute_command")
+ def test_run_no_cmd(self, mock_method=None):
+ self.assertEqual(self.feature.run(), testcase.TestCase.EX_RUN_ERROR)
+ mock_method.assert_not_called()
@mock.patch("functest.utils.functest_utils.execute_command",
return_value=1)
diff --git a/functest/tests/unit/features/test_copper.py b/functest/tests/unit/features/test_copper.py
deleted file mode 100644
index 56bf4137..00000000
--- a/functest/tests/unit/features/test_copper.py
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/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.constants import CONST
-
-
-class CopperTesting(unittest.TestCase):
-
- logging.disable(logging.CRITICAL)
-
- _case_name = "copper-notification"
- _project_name = "copper"
-
- def setUp(self):
- self.copper = copper.Copper(case_name=self._case_name,
- project_name=self._project_name)
-
- def test_init(self):
- self.assertEqual(self.copper.project_name, self._project_name)
- repo = CONST.__getattribute__('dir_repo_copper')
- self.assertEqual(
- self.copper.cmd,
- "cd {}/tests && bash run.sh && cd -".format(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
deleted file mode 100644
index 650d1509..00000000
--- a/functest/tests/unit/features/test_doctor.py
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/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.constants import CONST
-
-
-class DoctorTesting(unittest.TestCase):
-
- logging.disable(logging.CRITICAL)
-
- _case_name = "doctor-notification"
- _project_name = "doctor"
-
- def setUp(self):
- self.doctor = doctor.Doctor(case_name=self._case_name,
- project_name=self._project_name)
-
- def test_init(self):
- self.assertEqual(self.doctor.project_name, self._project_name)
- self.assertEqual(self.doctor.case_name, self._case_name)
- repo = CONST.__getattribute__('dir_repo_doctor')
- self.assertEqual(
- self.doctor.cmd,
- 'cd {}/tests && ./run.sh'.format(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
deleted file mode 100644
index f311af33..00000000
--- a/functest/tests/unit/features/test_domino.py
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/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.constants import CONST
-
-
-class DominoTesting(unittest.TestCase):
-
- logging.disable(logging.CRITICAL)
-
- _case_name = "domino-multinode"
- _project_name = "domino"
-
- def setUp(self):
- self.domino = domino.Domino(case_name=self._case_name,
- project_name=self._project_name)
-
- def test_init(self):
- self.assertEqual(self.domino.project_name, self._project_name)
- self.assertEqual(self.domino.case_name, self._case_name)
- repo = CONST.__getattribute__('dir_repo_domino')
- self.assertEqual(
- self.domino.cmd,
- 'cd {} && ./tests/run_multinode.sh'.format(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
deleted file mode 100644
index 96840195..00000000
--- a/functest/tests/unit/features/test_netready.py
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/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.constants import CONST
-
-
-class NetreadyTesting(unittest.TestCase):
-
- logging.disable(logging.CRITICAL)
-
- _case_name = "gluon_vping"
- _project_name = "netready"
-
- def setUp(self):
- self.netready = netready.GluonVping(case_name=self._case_name,
- project_name=self._project_name)
-
- def test_init(self):
- self.assertEqual(self.netready.project_name, self._project_name)
- self.assertEqual(self.netready.case_name, self._case_name)
- repo = CONST.__getattribute__('dir_repo_netready')
- self.assertEqual(
- self.netready.cmd,
- 'cd {}/test/functest && python ./gluon-test-suite.py'.format(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
deleted file mode 100644
index 5673e2b1..00000000
--- a/functest/tests/unit/features/test_odl_sfc.py
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/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.constants import CONST
-
-
-class OpenDaylightSFCTesting(unittest.TestCase):
-
- logging.disable(logging.CRITICAL)
-
- _case_name = "functest-odl-sfc"
- _project_name = "sfc"
-
- def setUp(self):
- self.odl_sfc = odl_sfc.OpenDaylightSFC(
- case_name="functest-odl-sfc",
- project_name=self._project_name)
-
- def test_init(self):
- self.assertEqual(self.odl_sfc.project_name, "sfc")
- self.assertEqual(self.odl_sfc.case_name, "functest-odl-sfc")
- repo = CONST.__getattribute__('dir_repo_sfc')
- dir_sfc_functest = '{}/sfc/tests/functest'.format(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
deleted file mode 100644
index 8fa1fba0..00000000
--- a/functest/tests/unit/features/test_promise.py
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/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.constants import CONST
-
-
-class PromiseTesting(unittest.TestCase):
-
- logging.disable(logging.CRITICAL)
-
- _case_name = "promise"
- _project_name = "promise"
-
- def setUp(self):
- self.promise = promise.Promise(case_name=self._case_name,
- project_name=self._project_name)
-
- def test_init(self):
- self.assertEqual(self.promise.project_name, self._project_name)
- self.assertEqual(self.promise.case_name, self._case_name)
- repo = CONST.__getattribute__('dir_repo_promise')
- self.assertEqual(
- self.promise.cmd,
- 'cd {}/promise/test/functest && python ./run_tests.py'.format(
- 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
deleted file mode 100644
index 75657fc4..00000000
--- a/functest/tests/unit/features/test_sdnvpn.py
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/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.constants import CONST
-
-
-class SdnVpnTesting(unittest.TestCase):
-
- logging.disable(logging.CRITICAL)
-
- _case_name = "bgpvpn"
- _project_name = "sdnvpn"
-
- def setUp(self):
- self.sdnvpn = sdnvpn.SdnVpnTests(case_name=self._case_name,
- project_name=self._project_name)
-
- def test_init(self):
- self.assertEqual(self.sdnvpn.project_name, self._project_name)
- self.assertEqual(self.sdnvpn.case_name, self._case_name)
- repo = CONST.__getattribute__('dir_repo_sdnvpn')
- self.assertEqual(
- self.sdnvpn.cmd,
- 'cd {}/sdnvpn/test/functest && python ./run_tests.py'.format(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
deleted file mode 100644
index 61ae9dc1..00000000
--- a/functest/tests/unit/features/test_security_scan.py
+++ /dev/null
@@ -1,44 +0,0 @@
-#!/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.constants import CONST
-
-
-class SecurityScanTesting(unittest.TestCase):
-
- logging.disable(logging.CRITICAL)
-
- _case_name = "security_scan"
- _project_name = "security_scan"
-
- def setUp(self):
- self.sscan = security_scan.SecurityScan(
- case_name=self._case_name, project_name=self._project_name)
-
- def test_init(self):
- self.assertEqual(self.sscan.project_name, self._project_name)
- self.assertEqual(self.sscan.case_name, self._case_name)
- repo = CONST.__getattribute__('dir_repo_securityscan')
- self.assertEqual(
- self.sscan.cmd, (
- '. {0}/stackrc && cd {1} && '
- 'python security_scan.py --config config.ini && '
- 'cd -'.format(
- CONST.__getattribute__("dir_functest_conf"),
- repo)))
-
-
-if __name__ == "__main__":
- unittest.main(verbosity=2)
diff --git a/functest/tests/unit/vnf/rnc/test_parser.py b/functest/tests/unit/vnf/rnc/test_parser.py
deleted file mode 100644
index 9e310cce..00000000
--- a/functest/tests/unit/vnf/rnc/test_parser.py
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/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.vnf.rnc import parser
-from functest.utils.constants import CONST
-
-
-class ParserTesting(unittest.TestCase):
-
- logging.disable(logging.CRITICAL)
-
- _case_name = "parser-basics"
- _project_name = "parser"
-
- def setUp(self):
- self.parser = parser.Parser(
- case_name=self._case_name, project_name=self._project_name)
-
- def test_init(self):
- self.assertEqual(self.parser.project_name, self._project_name)
- self.assertEqual(self.parser.case_name, self._case_name)
- repo = CONST.__getattribute__('dir_repo_parser')
- self.assertEqual(
- self.parser.cmd,
- 'cd {}/tests && ./functest_run.sh'.format(repo))
-
-
-if __name__ == "__main__":
- unittest.main(verbosity=2)