aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--functest/core/feature.py66
-rw-r--r--functest/opnfv_tests/features/barometer.py1
-rw-r--r--functest/opnfv_tests/features/copper.py7
-rw-r--r--functest/opnfv_tests/features/doctor.py7
-rw-r--r--functest/opnfv_tests/features/domino.py7
-rw-r--r--functest/opnfv_tests/features/netready.py11
-rw-r--r--functest/opnfv_tests/features/odl_sfc.py9
-rw-r--r--functest/opnfv_tests/features/promise.py9
-rw-r--r--functest/opnfv_tests/features/sdnvpn.py9
-rw-r--r--functest/opnfv_tests/features/security_scan.py14
-rw-r--r--functest/opnfv_tests/vnf/rnc/parser.py7
-rw-r--r--functest/tests/unit/core/test_feature.py126
-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
-rw-r--r--functest/tests/unit/vnf/rnc/test_parser.py8
22 files changed, 151 insertions, 215 deletions
diff --git a/functest/core/feature.py b/functest/core/feature.py
index 9f20a4269..29e0e9273 100644
--- a/functest/core/feature.py
+++ b/functest/core/feature.py
@@ -1,6 +1,6 @@
import time
-import testcase as base
+import functest.core.testcase as base
import functest.utils.functest_utils as ft_utils
import functest.utils.functest_logger as ft_logger
from functest.utils.constants import CONST
@@ -11,52 +11,34 @@ class Feature(base.TestCase):
def __init__(self, **kwargs):
super(Feature, self).__init__(**kwargs)
self.cmd = kwargs.get('cmd', '')
- repo = kwargs.get('repo', '')
- self.repo = CONST.__getattribute__(repo)
- self.result_file = self.get_result_file()
+ self.result_file = "{}/{}.log".format(
+ CONST.__getattribute__('dir_results'), self.project_name)
self.logger = ft_logger.Logger(self.project_name).getLogger()
+ def execute(self, **kwargs):
+ return -1
+
def run(self, **kwargs):
- self.prepare()
self.start_time = time.time()
- ret = self.execute()
+ exit_code = base.TestCase.EX_RUN_ERROR
+ self.criteria = "FAIL"
+ try:
+ if self.execute() == 0:
+ exit_code = base.TestCase.EX_OK
+ self.criteria = 'PASS'
+ ft_utils.logger_test_results(
+ self.project_name, self.case_name,
+ self.criteria, self.details)
+ self.logger.info("%s %s", self.project_name, self.criteria)
+ except Exception: # pylint: disable=broad-except
+ self.logger.exception("%s FAILED", self.project_name)
+ self.logger.info("Test result is stored in '%s'", self.result_file)
self.stop_time = time.time()
- self.post()
- self.parse_results(ret)
- self.log_results()
- self.logger.info("Test result is stored in '%s'" % self.result_file)
- return base.TestCase.EX_OK
-
- def execute(self):
- '''
- Executer method that can be overwritten
- By default it executes a shell command.
- '''
- return ft_utils.execute_command(self.cmd, output_file=self.result_file)
-
- def prepare(self, **kwargs):
- pass
-
- def post(self, **kwargs):
- pass
-
- def parse_results(self, ret):
- exit_code = base.TestCase.EX_OK
- if ret == 0:
- self.logger.info("{} OK".format(self.project_name))
- self.criteria = 'PASS'
- else:
- self.logger.info("{} FAILED".format(self.project_name))
- exit_code = base.TestCase.EX_RUN_ERROR
- self.criteria = "FAIL"
-
return exit_code
- def get_result_file(self):
- return "{}/{}.log".format(CONST.dir_results, self.project_name)
- def log_results(self):
- ft_utils.logger_test_results(self.project_name,
- self.case_name,
- self.criteria,
- self.details)
+class BashFeature(Feature):
+
+ def execute(self, **kwargs):
+ return ft_utils.execute_command(
+ self.cmd, output_file=self.result_file)
diff --git a/functest/opnfv_tests/features/barometer.py b/functest/opnfv_tests/features/barometer.py
index cd3062cc5..b42801d4b 100644
--- a/functest/opnfv_tests/features/barometer.py
+++ b/functest/opnfv_tests/features/barometer.py
@@ -17,7 +17,6 @@ class BarometerCollectd(base.Feature):
'''
def __init__(self, **kwargs):
- kwargs["repo"] = 'dir_repo_barometer'
super(BarometerCollectd, self).__init__(**kwargs)
def execute(self):
diff --git a/functest/opnfv_tests/features/copper.py b/functest/opnfv_tests/features/copper.py
index e5c3f8bdb..2c5459fc4 100644
--- a/functest/opnfv_tests/features/copper.py
+++ b/functest/opnfv_tests/features/copper.py
@@ -15,10 +15,11 @@
# limitations under the License.
#
import functest.core.feature as base
+from functest.utils.constants import CONST
-class Copper(base.Feature):
+class Copper(base.BashFeature):
def __init__(self, **kwargs):
- kwargs["repo"] = 'dir_repo_copper'
+ repo = CONST.__getattribute__('dir_repo_copper')
+ kwargs["cmd"] = 'cd %s/tests && bash run.sh && cd -' % repo
super(Copper, self).__init__(**kwargs)
- self.cmd = 'cd %s/tests && bash run.sh && cd -' % self.repo
diff --git a/functest/opnfv_tests/features/doctor.py b/functest/opnfv_tests/features/doctor.py
index 3a2cc7dfa..0e39248d8 100644
--- a/functest/opnfv_tests/features/doctor.py
+++ b/functest/opnfv_tests/features/doctor.py
@@ -14,10 +14,11 @@
#
#
import functest.core.feature as base
+from functest.utils.constants import CONST
-class Doctor(base.Feature):
+class Doctor(base.BashFeature):
def __init__(self, **kwargs):
- kwargs["repo"] = 'dir_repo_doctor'
+ repo = CONST.__getattribute__('dir_repo_doctor')
+ kwargs["cmd"] = 'cd %s/tests && ./run.sh' % repo
super(Doctor, self).__init__(**kwargs)
- self.cmd = 'cd %s/tests && ./run.sh' % self.repo
diff --git a/functest/opnfv_tests/features/domino.py b/functest/opnfv_tests/features/domino.py
index 629c8d54c..b5def3f3b 100644
--- a/functest/opnfv_tests/features/domino.py
+++ b/functest/opnfv_tests/features/domino.py
@@ -15,10 +15,11 @@
# 0.4: refactoring to match Test abstraction class
import functest.core.feature as base
+from functest.utils.constants import CONST
-class Domino(base.Feature):
+class Domino(base.BashFeature):
def __init__(self, **kwargs):
- kwargs["repo"] = 'dir_repo_domino'
+ repo = CONST.__getattribute__('dir_repo_domino')
+ kwargs["cmd"] = 'cd %s && ./tests/run_multinode.sh' % repo
super(Domino, self).__init__(**kwargs)
- self.cmd = 'cd %s && ./tests/run_multinode.sh' % self.repo
diff --git a/functest/opnfv_tests/features/netready.py b/functest/opnfv_tests/features/netready.py
index f7bab08be..717a4a348 100644
--- a/functest/opnfv_tests/features/netready.py
+++ b/functest/opnfv_tests/features/netready.py
@@ -9,13 +9,14 @@
#
import functest.core.feature as base
+from functest.utils.constants import CONST
-class GluonVping(base.Feature):
+class GluonVping(base.BashFeature):
def __init__(self, **kwargs):
- kwargs["repo"] = 'dir_repo_netready'
+ repo = CONST.__getattribute__('dir_repo_netready')
+ dir_netready_functest = '{}/test/functest'.format(repo)
+ kwargs["cmd"] = ('cd %s && python ./gluon-test-suite.py' %
+ dir_netready_functest)
super(GluonVping, self).__init__(**kwargs)
- dir_netready_functest = '{}/test/functest'.format(self.repo)
- self.cmd = ('cd %s && python ./gluon-test-suite.py' %
- dir_netready_functest)
diff --git a/functest/opnfv_tests/features/odl_sfc.py b/functest/opnfv_tests/features/odl_sfc.py
index d4f4eb67d..f5ecf7334 100644
--- a/functest/opnfv_tests/features/odl_sfc.py
+++ b/functest/opnfv_tests/features/odl_sfc.py
@@ -8,12 +8,13 @@
# http://www.apache.org/licenses/LICENSE-2.0
#
import functest.core.feature as base
+from functest.utils.constants import CONST
-class OpenDaylightSFC(base.Feature):
+class OpenDaylightSFC(base.BashFeature):
def __init__(self, **kwargs):
- kwargs["repo"] = 'dir_repo_sfc'
+ repo = CONST.__getattribute__('dir_repo_sfc')
+ dir_sfc_functest = '{}/sfc/tests/functest'.format(repo)
+ kwargs["cmd"] = 'cd %s && python ./run_tests.py' % dir_sfc_functest
super(OpenDaylightSFC, self).__init__(**kwargs)
- dir_sfc_functest = '{}/sfc/tests/functest'.format(self.repo)
- self.cmd = 'cd %s && python ./run_tests.py' % dir_sfc_functest
diff --git a/functest/opnfv_tests/features/promise.py b/functest/opnfv_tests/features/promise.py
index 49eb8a08c..b9e128f05 100644
--- a/functest/opnfv_tests/features/promise.py
+++ b/functest/opnfv_tests/features/promise.py
@@ -13,11 +13,12 @@
# limitations under the License.
#
import functest.core.feature as base
+from functest.utils.constants import CONST
-class Promise(base.Feature):
+class Promise(base.BashFeature):
def __init__(self, **kwargs):
- kwargs["repo"] = 'dir_repo_promise'
+ repo = CONST.__getattribute__('dir_repo_promise')
+ dir_promise_functest = '{}/promise/test/functest'.format(repo)
+ kwargs["cmd"] = 'cd %s && python ./run_tests.py' % dir_promise_functest
super(Promise, self).__init__(**kwargs)
- dir_promise_functest = '{}/promise/test/functest'.format(self.repo)
- self.cmd = 'cd %s && python ./run_tests.py' % dir_promise_functest
diff --git a/functest/opnfv_tests/features/sdnvpn.py b/functest/opnfv_tests/features/sdnvpn.py
index 6a1071fff..10a97e926 100644
--- a/functest/opnfv_tests/features/sdnvpn.py
+++ b/functest/opnfv_tests/features/sdnvpn.py
@@ -8,12 +8,13 @@
# http://www.apache.org/licenses/LICENSE-2.0
#
import functest.core.feature as base
+from functest.utils.constants import CONST
-class SdnVpnTests(base.Feature):
+class SdnVpnTests(base.BashFeature):
def __init__(self, **kwargs):
- kwargs["repo"] = 'dir_repo_sdnvpn'
+ repo = CONST.__getattribute__('dir_repo_sdnvpn')
+ dir_sfc_functest = '{}/sdnvpn/test/functest'.format(repo)
+ kwargs["cmd"] = 'cd %s && python ./run_tests.py' % dir_sfc_functest
super(SdnVpnTests, self).__init__(**kwargs)
- dir_sfc_functest = '{}/sdnvpn/test/functest'.format(self.repo)
- self.cmd = 'cd %s && python ./run_tests.py' % dir_sfc_functest
diff --git a/functest/opnfv_tests/features/security_scan.py b/functest/opnfv_tests/features/security_scan.py
index 2ed9a823a..8f167259c 100644
--- a/functest/opnfv_tests/features/security_scan.py
+++ b/functest/opnfv_tests/features/security_scan.py
@@ -12,12 +12,12 @@ import functest.core.feature as base
from functest.utils.constants import CONST
-class SecurityScan(base.Feature):
+class SecurityScan(base.BashFeature):
def __init__(self, **kwargs):
- kwargs["repo"] = 'dir_repo_securityscan'
+ repo = CONST.__getattribute__('dir_repo_securityscan')
+ conf = CONST.__getattribute__('dir_functest_conf')
+ kwargs["cmd"] = ('. {0}/stackrc && '
+ 'cd {1} && '
+ 'python security_scan.py --config config.ini && '
+ 'cd -'.format(conf, repo))
super(SecurityScan, self).__init__(**kwargs)
- self.cmd = ('. {0}/stackrc && '
- 'cd {1} && '
- 'python security_scan.py --config config.ini && '
- 'cd -'.format(CONST.dir_functest_conf,
- self.repo))
diff --git a/functest/opnfv_tests/vnf/rnc/parser.py b/functest/opnfv_tests/vnf/rnc/parser.py
index ff726b9ea..3e6b138c2 100644
--- a/functest/opnfv_tests/vnf/rnc/parser.py
+++ b/functest/opnfv_tests/vnf/rnc/parser.py
@@ -16,10 +16,11 @@
#
import functest.core.feature as base
+from functest.utils.constants import CONST
-class Parser(base.Feature):
+class Parser(base.BashFeature):
def __init__(self, **kwargs):
- kwargs["repo"] = 'dir_repo_parser'
+ repo = CONST.__getattribute__('dir_repo_parser')
+ kwargs["cmd"] = 'cd %s/tests && ./functest_run.sh' % repo
super(Parser, self).__init__(**kwargs)
- self.cmd = 'cd %s/tests && ./functest_run.sh' % self.repo
diff --git a/functest/tests/unit/core/test_feature.py b/functest/tests/unit/core/test_feature.py
index 0ed178a1d..ac4b04c44 100644
--- a/functest/tests/unit/core/test_feature.py
+++ b/functest/tests/unit/core/test_feature.py
@@ -16,92 +16,68 @@ import mock
from functest.core import feature
from functest.core import testcase
-from functest.utils import constants
+logging.disable(logging.CRITICAL)
-class FeatureInitTesting(unittest.TestCase):
- logging.disable(logging.CRITICAL)
+class FeatureTestingBase(unittest.TestCase):
- @unittest.skip("JIRA: FUNCTEST-780")
- def test_init_with_wrong_repo(self):
- with self.assertRaises(ValueError):
- feature.Feature(repo='foo')
+ _case_name = "foo"
+ _project_name = "bar"
+ _repo = "dir_repo_copper"
+ _cmd = "cd /home/opnfv/repos/foo/tests && bash run.sh && cd -"
+ _output_file = '/home/opnfv/functest/results/bar.log'
- 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'))
+ @mock.patch('time.time', side_effect=[1, 2])
+ def _test_run(self, status, mock_method=None):
+ self.assertEqual(self.feature.run(), status)
+ if status == testcase.TestCase.EX_OK:
+ self.assertEqual(self.feature.criteria, 'PASS')
+ else:
+ self.assertEqual(self.feature.criteria, 'FAIL')
+ mock_method.assert_has_calls([mock.call(), mock.call()])
+ self.assertEqual(self.feature.start_time, 1)
+ self.assertEqual(self.feature.stop_time, 2)
-class FeatureTesting(unittest.TestCase):
-
- logging.disable(logging.CRITICAL)
+class FeatureTesting(FeatureTestingBase):
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()
+ self.feature = feature.Feature(
+ project_name=self._project_name, case_name=self._case_name,
+ cmd=self._cmd)
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()
+ self._test_run(testcase.TestCase.EX_RUN_ERROR)
+
+
+class BashFeatureTesting(FeatureTestingBase):
+
+ def setUp(self):
+ self.feature = feature.BashFeature(
+ project_name=self._project_name, case_name=self._case_name,
+ cmd=self._cmd)
+
+ @mock.patch("functest.utils.functest_utils.execute_command",
+ return_value=1)
+ def test_run_ko(self, mock_method=None):
+ self._test_run(testcase.TestCase.EX_RUN_ERROR)
+ mock_method.assert_called_once_with(
+ self._cmd, output_file=self._output_file)
+
+ @mock.patch("functest.utils.functest_utils.execute_command",
+ side_effect=Exception)
+ def test_run_exc(self, mock_method=None):
+ self._test_run(testcase.TestCase.EX_RUN_ERROR)
+ mock_method.assert_called_once_with(
+ self._cmd, output_file=self._output_file)
+
+ @mock.patch("functest.utils.functest_utils.execute_command",
+ return_value=0)
+ def test_run(self, mock_method):
+ self._test_run(testcase.TestCase.EX_OK)
+ mock_method.assert_called_once_with(
+ self._cmd, output_file=self._output_file)
if __name__ == "__main__":
diff --git a/functest/tests/unit/features/test_barometer.py b/functest/tests/unit/features/test_barometer.py
index 8afb56df0..8ca463b24 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 e4ddc1497..56bf41370 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 a8512883f..650d1509e 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 27353a4d8..f311af33d 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 1a88e78a2..968401950 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 439d59654..5673e2b18 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 2af9c6708..8fa1fba04 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 dd67d8b41..75657fc41 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 081bf1f6a..61ae9dc15 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__":
diff --git a/functest/tests/unit/vnf/rnc/test_parser.py b/functest/tests/unit/vnf/rnc/test_parser.py
index 3a181fe85..9e310ccee 100644
--- a/functest/tests/unit/vnf/rnc/test_parser.py
+++ b/functest/tests/unit/vnf/rnc/test_parser.py
@@ -13,7 +13,7 @@ import logging
import unittest
from functest.opnfv_tests.vnf.rnc import parser
-from functest.utils import constants
+from functest.utils.constants import CONST
class ParserTesting(unittest.TestCase):
@@ -30,12 +30,10 @@ class ParserTesting(unittest.TestCase):
def test_init(self):
self.assertEqual(self.parser.project_name, self._project_name)
self.assertEqual(self.parser.case_name, self._case_name)
- self.assertEqual(
- self.parser.repo,
- constants.CONST.__getattribute__("dir_repo_parser"))
+ repo = CONST.__getattribute__('dir_repo_parser')
self.assertEqual(
self.parser.cmd,
- 'cd {}/tests && ./functest_run.sh'.format(self.parser.repo))
+ 'cd {}/tests && ./functest_run.sh'.format(repo))
if __name__ == "__main__":