aboutsummaryrefslogtreecommitdiffstats
path: root/functest/tests
diff options
context:
space:
mode:
Diffstat (limited to 'functest/tests')
-rw-r--r--functest/tests/unit/ci/test_check_deployment.py7
-rw-r--r--functest/tests/unit/ci/test_run_tests.py24
-rw-r--r--functest/tests/unit/ci/test_tier_builder.py2
-rw-r--r--functest/tests/unit/ci/test_tier_handler.py8
-rw-r--r--functest/tests/unit/core/test_testcase.py46
5 files changed, 26 insertions, 61 deletions
diff --git a/functest/tests/unit/ci/test_check_deployment.py b/functest/tests/unit/ci/test_check_deployment.py
index 66d1b7af..fa2f2130 100644
--- a/functest/tests/unit/ci/test_check_deployment.py
+++ b/functest/tests/unit/ci/test_check_deployment.py
@@ -172,11 +172,14 @@ class CheckDeploymentTesting(unittest.TestCase):
@mock.patch('functest.ci.check_deployment.LOGGER.info')
@mock.patch('functest.opnfv_tests.openstack.snaps.snaps_utils.'
- 'get_ext_net_name', return_value='ext-net')
+ 'get_ext_net_name')
def test_check_extnet(self, mock_getext, mock_loginfo):
+ test_network = 'ext-net'
+ mock_getext.return_value = test_network
self.deployment.check_ext_net()
self.assertTrue(mock_getext.called)
- mock_loginfo.assert_called_once_with("External network found: ext-net")
+ mock_loginfo.assert_called_once_with(
+ "External network found: %s", test_network)
@mock.patch('functest.opnfv_tests.openstack.snaps.snaps_utils.'
'get_ext_net_name', return_value='')
diff --git a/functest/tests/unit/ci/test_run_tests.py b/functest/tests/unit/ci/test_run_tests.py
index bc95f8f3..93cbfccd 100644
--- a/functest/tests/unit/ci/test_run_tests.py
+++ b/functest/tests/unit/ci/test_run_tests.py
@@ -58,14 +58,14 @@ class RunTestsTesting(unittest.TestCase):
self.run_tests_parser = run_tests.RunTestsParser()
- @mock.patch('functest.ci.run_tests.logger.error')
+ @mock.patch('functest.ci.run_tests.LOGGER.error')
def test_source_rc_file_missing_file(self, mock_logger_error):
with mock.patch('functest.ci.run_tests.os.path.isfile',
return_value=False), \
self.assertRaises(Exception):
self.runner.source_rc_file()
- @mock.patch('functest.ci.run_tests.logger.debug')
+ @mock.patch('functest.ci.run_tests.LOGGER.debug')
@mock.patch('functest.ci.run_tests.os.path.isfile',
return_value=True)
def test_source_rc_file_default(self, *args):
@@ -81,7 +81,7 @@ class RunTestsTesting(unittest.TestCase):
self.assertEqual(self.runner.get_run_dict('test_name'),
mock_obj)
- @mock.patch('functest.ci.run_tests.logger.error')
+ @mock.patch('functest.ci.run_tests.LOGGER.error')
def test_get_run_dict_if_defined_missing_config_option(self,
mock_logger_error):
with mock.patch('functest.ci.run_tests.'
@@ -90,9 +90,8 @@ class RunTestsTesting(unittest.TestCase):
testname = 'test_name'
self.assertEqual(self.runner.get_run_dict(testname),
None)
- mock_logger_error.assert_called_once_with("Cannot get {}'s config "
- "options"
- .format(testname))
+ mock_logger_error.assert_called_once_with(
+ "Cannot get %s's config options", testname)
with mock.patch('functest.ci.run_tests.'
'ft_utils.get_dict_by_test',
@@ -101,7 +100,7 @@ class RunTestsTesting(unittest.TestCase):
self.assertEqual(self.runner.get_run_dict(testname),
None)
- @mock.patch('functest.ci.run_tests.logger.exception')
+ @mock.patch('functest.ci.run_tests.LOGGER.exception')
def test_get_run_dict_if_defined_exception(self,
mock_logger_except):
with mock.patch('functest.ci.run_tests.'
@@ -110,9 +109,8 @@ class RunTestsTesting(unittest.TestCase):
testname = 'test_name'
self.assertEqual(self.runner.get_run_dict(testname),
None)
- mock_logger_except.assert_called_once_with("Cannot get {}'s config"
- " options"
- .format(testname))
+ mock_logger_except.assert_called_once_with(
+ "Cannot get %s's config options", testname)
def test_run_tests_import_test_class_exception(self):
mock_test = mock.Mock()
@@ -153,14 +151,14 @@ class RunTestsTesting(unittest.TestCase):
run_tests.Result.EX_OK)
mock_methods[0].assert_called_with(mock.ANY)
- @mock.patch('functest.ci.run_tests.logger.info')
+ @mock.patch('functest.ci.run_tests.LOGGER.info')
def test_run_tier_missing_test(self, mock_logger_info):
self.tier.get_tests.return_value = None
self.assertEqual(self.runner.run_tier(self.tier),
run_tests.Result.EX_ERROR)
self.assertTrue(mock_logger_info.called)
- @mock.patch('functest.ci.run_tests.logger.info')
+ @mock.patch('functest.ci.run_tests.LOGGER.info')
@mock.patch('functest.ci.run_tests.Runner.run_tier')
@mock.patch('functest.ci.run_tests.Runner.summary')
def test_run_all_default(self, *mock_methods):
@@ -169,7 +167,7 @@ class RunTestsTesting(unittest.TestCase):
mock_methods[1].assert_not_called()
self.assertTrue(mock_methods[2].called)
- @mock.patch('functest.ci.run_tests.logger.info')
+ @mock.patch('functest.ci.run_tests.LOGGER.info')
@mock.patch('functest.ci.run_tests.Runner.summary')
def test_run_all_missing_tier(self, *mock_methods):
CONST.__setattr__('CI_LOOP', 'loop_re_not_available')
diff --git a/functest/tests/unit/ci/test_tier_builder.py b/functest/tests/unit/ci/test_tier_builder.py
index 1dec9aed..d832ca3f 100644
--- a/functest/tests/unit/ci/test_tier_builder.py
+++ b/functest/tests/unit/ci/test_tier_builder.py
@@ -5,6 +5,8 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
+# pylint: disable=missing-docstring
+
import logging
import unittest
diff --git a/functest/tests/unit/ci/test_tier_handler.py b/functest/tests/unit/ci/test_tier_handler.py
index 1909ac22..871220db 100644
--- a/functest/tests/unit/ci/test_tier_handler.py
+++ b/functest/tests/unit/ci/test_tier_handler.py
@@ -5,6 +5,8 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
+# pylint: disable=missing-docstring
+
import logging
import unittest
@@ -89,11 +91,11 @@ class TierHandlerTesting(unittest.TestCase):
self.assertEqual(self.tier.get_ci_loop(),
'test_ci_loop')
- def test_testcase_is_none_present_item(self):
+ def test_testcase_is_none_in_item(self):
self.assertEqual(tier_handler.TestCase.is_none("item"),
False)
- def test_testcase_is_none_missing_item(self):
+ def test_testcase_is_none_no_item(self):
self.assertEqual(tier_handler.TestCase.is_none(None),
True)
@@ -102,7 +104,7 @@ class TierHandlerTesting(unittest.TestCase):
'test_scenario'),
True)
- def test_testcase_is_compatible_missing_installer_scenario(self):
+ def test_testcase_is_compatible_2(self):
self.assertEqual(self.testcase.is_compatible('missing_installer',
'test_scenario'),
False)
diff --git a/functest/tests/unit/core/test_testcase.py b/functest/tests/unit/core/test_testcase.py
index 0a6f0c9f..6fbf62e2 100644
--- a/functest/tests/unit/core/test_testcase.py
+++ b/functest/tests/unit/core/test_testcase.py
@@ -12,15 +12,17 @@
import logging
import unittest
+from functest.core import testcase
+
import mock
-from functest.core import testcase
__author__ = "Cedric Ollivier <cedric.ollivier@orange.com>"
class TestCaseTesting(unittest.TestCase):
"""The class testing TestCase."""
+
# pylint: disable=missing-docstring,too-many-public-methods
_case_name = "base"
@@ -229,48 +231,6 @@ class TestCaseTesting(unittest.TestCase):
self.assertEqual(self.test.clean(), None)
-class OSGCTestCaseTesting(unittest.TestCase):
- """The class testing OSGCTestCase."""
- # pylint: disable=missing-docstring
-
- def setUp(self):
- self.test = testcase.OSGCTestCase()
-
- @mock.patch('functest.utils.openstack_snapshot.main',
- side_effect=Exception)
- def test_create_snapshot_exc(self, mock_method=None):
- self.assertEqual(self.test.create_snapshot(),
- testcase.TestCase.EX_RUN_ERROR)
- mock_method.assert_called_once_with()
-
- @mock.patch('functest.utils.openstack_snapshot.main', return_value=-1)
- def test_create_snapshot_ko(self, mock_method=None):
- self.assertEqual(self.test.create_snapshot(),
- testcase.TestCase.EX_RUN_ERROR)
- mock_method.assert_called_once_with()
-
- @mock.patch('functest.utils.openstack_snapshot.main', return_value=0)
- def test_create_snapshot_env(self, mock_method=None):
- self.assertEqual(self.test.create_snapshot(),
- testcase.TestCase.EX_OK)
- mock_method.assert_called_once_with()
-
- @mock.patch('functest.utils.openstack_clean.main', side_effect=Exception)
- def test_clean_exc(self, mock_method=None):
- self.assertEqual(self.test.clean(), None)
- mock_method.assert_called_once_with()
-
- @mock.patch('functest.utils.openstack_clean.main', return_value=-1)
- def test_clean_ko(self, mock_method=None):
- self.assertEqual(self.test.clean(), None)
- mock_method.assert_called_once_with()
-
- @mock.patch('functest.utils.openstack_clean.main', return_value=0)
- def test_clean(self, mock_method=None):
- self.assertEqual(self.test.clean(), None)
- mock_method.assert_called_once_with()
-
-
if __name__ == "__main__":
logging.disable(logging.CRITICAL)
unittest.main(verbosity=2)