aboutsummaryrefslogtreecommitdiffstats
path: root/functest/tests/unit/features
diff options
context:
space:
mode:
authorCédric Ollivier <cedric.ollivier@orange.com>2017-04-10 15:10:11 +0200
committerCédric Ollivier <cedric.ollivier@orange.com>2017-04-12 16:26:12 +0200
commit888271575907898d80081e69b37f879091a636fc (patch)
treef6b4735f11464d3f94771575ca07af447003e865 /functest/tests/unit/features
parent96bacd7d8ffb9c05672c0a1fc6e68d19e4a6793a (diff)
Refactor the Feature framework
run() returns the expected status code (see following JIRA tickets). repo, pre() and post() are removed as they were quite useless. A dedicated class is proposed for bash programs. Unit tests have been added to fully cover this module. All features have been modified to conform with these modifications. It also removes the decorators which skipped several unit tests. JIRA: FUNCTEST-778 JIRA: FUNCTEST-779 JIRA: FUNCTEST-780 JIRA: FUNCTEST-781 Change-Id: Ifb1e4c4f68260a4e20d895f67f07f369ca959374 Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
Diffstat (limited to 'functest/tests/unit/features')
-rw-r--r--functest/tests/unit/features/test_barometer.py16
-rw-r--r--functest/tests/unit/features/test_copper.py9
-rw-r--r--functest/tests/unit/features/test_doctor.py8
-rw-r--r--functest/tests/unit/features/test_domino.py8
-rw-r--r--functest/tests/unit/features/test_netready.py9
-rw-r--r--functest/tests/unit/features/test_odl_sfc.py8
-rw-r--r--functest/tests/unit/features/test_promise.py8
-rw-r--r--functest/tests/unit/features/test_sdnvpn.py9
-rw-r--r--functest/tests/unit/features/test_security_scan.py10
9 files changed, 29 insertions, 56 deletions
diff --git a/functest/tests/unit/features/test_barometer.py b/functest/tests/unit/features/test_barometer.py
index 8afb56df..8ca463b2 100644
--- a/functest/tests/unit/features/test_barometer.py
+++ b/functest/tests/unit/features/test_barometer.py
@@ -19,7 +19,6 @@ 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):
@@ -36,22 +35,15 @@ class BarometerTesting(unittest.TestCase):
def test_init(self):
self.assertEqual(self.barometer.project_name, self._project_name)
self.assertEqual(self.barometer.case_name, self._case_name)
- 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
+ def test_run_ko(self):
sys.modules['baro_tests'].collectd.main = mock.Mock(return_value=1)
- self.assertEqual(self.barometer.execute(),
+ self.assertEqual(self.barometer.run(),
testcase.TestCase.EX_RUN_ERROR)
- @unittest.skip("JIRA: FUNCTEST-777")
- def test_execute(self):
- # It must be skipped to allow merging
+ def test_run(self):
sys.modules['baro_tests'].collectd.main = mock.Mock(return_value=0)
- self.assertEqual(self.barometer.execute(), testcase.TestCase.EX_OK)
+ self.assertEqual(self.barometer.run(), testcase.TestCase.EX_OK)
if __name__ == "__main__":
diff --git a/functest/tests/unit/features/test_copper.py b/functest/tests/unit/features/test_copper.py
index e4ddc149..56bf4137 100644
--- a/functest/tests/unit/features/test_copper.py
+++ b/functest/tests/unit/features/test_copper.py
@@ -13,7 +13,7 @@ import logging
import unittest
from functest.opnfv_tests.features import copper
-from functest.utils import constants
+from functest.utils.constants import CONST
class CopperTesting(unittest.TestCase):
@@ -29,13 +29,10 @@ class CopperTesting(unittest.TestCase):
def test_init(self):
self.assertEqual(self.copper.project_name, self._project_name)
- self.assertEqual(self.copper.case_name, self._case_name)
- self.assertEqual(
- self.copper.repo,
- constants.CONST.__getattribute__("dir_repo_copper"))
+ repo = CONST.__getattribute__('dir_repo_copper')
self.assertEqual(
self.copper.cmd,
- "cd {}/tests && bash run.sh && cd -".format(self.copper.repo))
+ "cd {}/tests && bash run.sh && cd -".format(repo))
if __name__ == "__main__":
diff --git a/functest/tests/unit/features/test_doctor.py b/functest/tests/unit/features/test_doctor.py
index a8512883..650d1509 100644
--- a/functest/tests/unit/features/test_doctor.py
+++ b/functest/tests/unit/features/test_doctor.py
@@ -13,7 +13,7 @@ import logging
import unittest
from functest.opnfv_tests.features import doctor
-from functest.utils import constants
+from functest.utils.constants import CONST
class DoctorTesting(unittest.TestCase):
@@ -30,12 +30,10 @@ class DoctorTesting(unittest.TestCase):
def test_init(self):
self.assertEqual(self.doctor.project_name, self._project_name)
self.assertEqual(self.doctor.case_name, self._case_name)
- self.assertEqual(
- self.doctor.repo,
- constants.CONST.__getattribute__("dir_repo_doctor"))
+ repo = CONST.__getattribute__('dir_repo_doctor')
self.assertEqual(
self.doctor.cmd,
- 'cd {}/tests && ./run.sh'.format(self.doctor.repo))
+ 'cd {}/tests && ./run.sh'.format(repo))
if __name__ == "__main__":
diff --git a/functest/tests/unit/features/test_domino.py b/functest/tests/unit/features/test_domino.py
index 27353a4d..f311af33 100644
--- a/functest/tests/unit/features/test_domino.py
+++ b/functest/tests/unit/features/test_domino.py
@@ -13,7 +13,7 @@ import logging
import unittest
from functest.opnfv_tests.features import domino
-from functest.utils import constants
+from functest.utils.constants import CONST
class DominoTesting(unittest.TestCase):
@@ -30,12 +30,10 @@ class DominoTesting(unittest.TestCase):
def test_init(self):
self.assertEqual(self.domino.project_name, self._project_name)
self.assertEqual(self.domino.case_name, self._case_name)
- self.assertEqual(
- self.domino.repo,
- constants.CONST.__getattribute__("dir_repo_domino"))
+ repo = CONST.__getattribute__('dir_repo_domino')
self.assertEqual(
self.domino.cmd,
- 'cd {} && ./tests/run_multinode.sh'.format(self.domino.repo))
+ 'cd {} && ./tests/run_multinode.sh'.format(repo))
if __name__ == "__main__":
diff --git a/functest/tests/unit/features/test_netready.py b/functest/tests/unit/features/test_netready.py
index 1a88e78a..96840195 100644
--- a/functest/tests/unit/features/test_netready.py
+++ b/functest/tests/unit/features/test_netready.py
@@ -13,7 +13,7 @@ import logging
import unittest
from functest.opnfv_tests.features import netready
-from functest.utils import constants
+from functest.utils.constants import CONST
class NetreadyTesting(unittest.TestCase):
@@ -30,13 +30,10 @@ class NetreadyTesting(unittest.TestCase):
def test_init(self):
self.assertEqual(self.netready.project_name, self._project_name)
self.assertEqual(self.netready.case_name, self._case_name)
- self.assertEqual(
- self.netready.repo,
- constants.CONST.__getattribute__("dir_repo_netready"))
+ repo = CONST.__getattribute__('dir_repo_netready')
self.assertEqual(
self.netready.cmd,
- 'cd {}/test/functest && python ./gluon-test-suite.py'.format(
- self.netready.repo))
+ 'cd {}/test/functest && python ./gluon-test-suite.py'.format(repo))
if __name__ == "__main__":
diff --git a/functest/tests/unit/features/test_odl_sfc.py b/functest/tests/unit/features/test_odl_sfc.py
index 439d5965..5673e2b1 100644
--- a/functest/tests/unit/features/test_odl_sfc.py
+++ b/functest/tests/unit/features/test_odl_sfc.py
@@ -13,7 +13,7 @@ import logging
import unittest
from functest.opnfv_tests.features import odl_sfc
-from functest.utils import constants
+from functest.utils.constants import CONST
class OpenDaylightSFCTesting(unittest.TestCase):
@@ -31,10 +31,8 @@ class OpenDaylightSFCTesting(unittest.TestCase):
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)
+ 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))
diff --git a/functest/tests/unit/features/test_promise.py b/functest/tests/unit/features/test_promise.py
index 2af9c670..8fa1fba0 100644
--- a/functest/tests/unit/features/test_promise.py
+++ b/functest/tests/unit/features/test_promise.py
@@ -13,7 +13,7 @@ import logging
import unittest
from functest.opnfv_tests.features import promise
-from functest.utils import constants
+from functest.utils.constants import CONST
class PromiseTesting(unittest.TestCase):
@@ -30,13 +30,11 @@ class PromiseTesting(unittest.TestCase):
def test_init(self):
self.assertEqual(self.promise.project_name, self._project_name)
self.assertEqual(self.promise.case_name, self._case_name)
- self.assertEqual(
- self.promise.repo,
- constants.CONST.__getattribute__("dir_repo_promise"))
+ repo = CONST.__getattribute__('dir_repo_promise')
self.assertEqual(
self.promise.cmd,
'cd {}/promise/test/functest && python ./run_tests.py'.format(
- self.promise.repo))
+ repo))
if __name__ == "__main__":
diff --git a/functest/tests/unit/features/test_sdnvpn.py b/functest/tests/unit/features/test_sdnvpn.py
index dd67d8b4..75657fc4 100644
--- a/functest/tests/unit/features/test_sdnvpn.py
+++ b/functest/tests/unit/features/test_sdnvpn.py
@@ -13,7 +13,7 @@ import logging
import unittest
from functest.opnfv_tests.features import sdnvpn
-from functest.utils import constants
+from functest.utils.constants import CONST
class SdnVpnTesting(unittest.TestCase):
@@ -30,13 +30,10 @@ class SdnVpnTesting(unittest.TestCase):
def test_init(self):
self.assertEqual(self.sdnvpn.project_name, self._project_name)
self.assertEqual(self.sdnvpn.case_name, self._case_name)
- self.assertEqual(
- self.sdnvpn.repo,
- constants.CONST.__getattribute__("dir_repo_sdnvpn"))
+ repo = CONST.__getattribute__('dir_repo_sdnvpn')
self.assertEqual(
self.sdnvpn.cmd,
- 'cd {}/sdnvpn/test/functest && python ./run_tests.py'.format(
- self.sdnvpn.repo))
+ 'cd {}/sdnvpn/test/functest && python ./run_tests.py'.format(repo))
if __name__ == "__main__":
diff --git a/functest/tests/unit/features/test_security_scan.py b/functest/tests/unit/features/test_security_scan.py
index 081bf1f6..61ae9dc1 100644
--- a/functest/tests/unit/features/test_security_scan.py
+++ b/functest/tests/unit/features/test_security_scan.py
@@ -13,7 +13,7 @@ import logging
import unittest
from functest.opnfv_tests.features import security_scan
-from functest.utils import constants
+from functest.utils.constants import CONST
class SecurityScanTesting(unittest.TestCase):
@@ -30,16 +30,14 @@ class SecurityScanTesting(unittest.TestCase):
def test_init(self):
self.assertEqual(self.sscan.project_name, self._project_name)
self.assertEqual(self.sscan.case_name, self._case_name)
- self.assertEqual(
- self.sscan.repo,
- constants.CONST.__getattribute__("dir_repo_securityscan"))
+ repo = 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)))
+ CONST.__getattribute__("dir_functest_conf"),
+ repo)))
if __name__ == "__main__":