aboutsummaryrefslogtreecommitdiffstats
path: root/functest/tests
diff options
context:
space:
mode:
authorCédric Ollivier <cedric.ollivier@orange.com>2017-04-23 08:59:43 +0200
committerCédric Ollivier <cedric.ollivier@orange.com>2017-04-26 09:35:47 +0200
commite620488a6747318c40eb973c2607ae6d44e95b8f (patch)
tree7654490079abb39af4a48b2edf249efc66cb9874 /functest/tests
parent9d4e6cb10fef5f0cef104861034340cda5e48a3e (diff)
Switch TestCase attribute criteria to result
It mainly avoids mixing input and output. Criteria is now an input set in functest/ci/testcases.yaml and then must be passed as __init__() args (which will be proposed in an additional change). Then it also renames the related TestCase method to check_result(). Change-Id: Ifc3c8e3ea6cde7e3edf7174bed4bf2bf0894e8e3 Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
Diffstat (limited to 'functest/tests')
-rw-r--r--functest/tests/unit/core/test_feature.py4
-rw-r--r--functest/tests/unit/core/test_testcase.py28
-rw-r--r--functest/tests/unit/core/test_vnf_base.py2
-rw-r--r--functest/tests/unit/odl/test_odl.py2
-rw-r--r--functest/tests/unit/utils/test_functest_utils.py9
5 files changed, 23 insertions, 22 deletions
diff --git a/functest/tests/unit/core/test_feature.py b/functest/tests/unit/core/test_feature.py
index bd7197f0..97075223 100644
--- a/functest/tests/unit/core/test_feature.py
+++ b/functest/tests/unit/core/test_feature.py
@@ -35,9 +35,9 @@ class FeatureTestingBase(unittest.TestCase):
def _test_run(self, status, mock_method=None):
self.assertEqual(self.feature.run(cmd=self._cmd), status)
if status == testcase.TestCase.EX_OK:
- self.assertEqual(self.feature.criteria, 'PASS')
+ self.assertEqual(self.feature.result, 'PASS')
else:
- self.assertEqual(self.feature.criteria, 'FAIL')
+ self.assertEqual(self.feature.result, 'FAIL')
mock_method.assert_has_calls([mock.call(), mock.call()])
self.assertEqual(self.feature.start_time, 1)
self.assertEqual(self.feature.stop_time, 2)
diff --git a/functest/tests/unit/core/test_testcase.py b/functest/tests/unit/core/test_testcase.py
index 4f3b25cc..b93f50d6 100644
--- a/functest/tests/unit/core/test_testcase.py
+++ b/functest/tests/unit/core/test_testcase.py
@@ -34,7 +34,7 @@ class TestCaseTesting(unittest.TestCase):
project_name=self._project_name)
self.test.start_time = "1"
self.test.stop_time = "2"
- self.test.criteria = "PASS"
+ self.test.result = "PASS"
self.test.details = {"Hello": "World"}
def test_run_unimplemented(self):
@@ -57,7 +57,7 @@ class TestCaseTesting(unittest.TestCase):
self._test_missing_attribute()
def test_missing_criteria(self):
- self.test.criteria = None
+ self.test.result = None
self._test_missing_attribute()
def test_missing_start_time(self):
@@ -76,7 +76,7 @@ class TestCaseTesting(unittest.TestCase):
testcase.TestCase.EX_OK)
mock_function.assert_called_once_with(
self._project_name, self._case_name, self.test.start_time,
- self.test.stop_time, self.test.criteria, self.test.details)
+ self.test.stop_time, self.test.result, self.test.details)
@mock.patch('functest.utils.functest_utils.push_results_to_db',
return_value=False)
@@ -85,7 +85,7 @@ class TestCaseTesting(unittest.TestCase):
testcase.TestCase.EX_PUSH_TO_DB_ERROR)
mock_function.assert_called_once_with(
self._project_name, self._case_name, self.test.start_time,
- self.test.stop_time, self.test.criteria, self.test.details)
+ self.test.stop_time, self.test.result, self.test.details)
@mock.patch('functest.utils.functest_utils.push_results_to_db',
return_value=True)
@@ -94,21 +94,21 @@ class TestCaseTesting(unittest.TestCase):
testcase.TestCase.EX_OK)
mock_function.assert_called_once_with(
self._project_name, self._case_name, self.test.start_time,
- self.test.stop_time, self.test.criteria, self.test.details)
+ self.test.stop_time, self.test.result, self.test.details)
- def test_check_criteria_missing(self):
- self.test.criteria = None
- self.assertEqual(self.test.check_criteria(),
+ def test_check_result_missing(self):
+ self.test.result = None
+ self.assertEqual(self.test.check_result(),
testcase.TestCase.EX_TESTCASE_FAILED)
- def test_check_criteria_failed(self):
- self.test.criteria = 'FAILED'
- self.assertEqual(self.test.check_criteria(),
+ def test_check_result_failed(self):
+ self.test.result = 'FAILED'
+ self.assertEqual(self.test.check_result(),
testcase.TestCase.EX_TESTCASE_FAILED)
- def test_check_criteria_pass(self):
- self.test.criteria = 'PASS'
- self.assertEqual(self.test.check_criteria(),
+ def test_check_result_pass(self):
+ self.test.result = 'PASS'
+ self.assertEqual(self.test.check_result(),
testcase.TestCase.EX_OK)
diff --git a/functest/tests/unit/core/test_vnf_base.py b/functest/tests/unit/core/test_vnf_base.py
index 96706040..540cf610 100644
--- a/functest/tests/unit/core/test_vnf_base.py
+++ b/functest/tests/unit/core/test_vnf_base.py
@@ -23,7 +23,7 @@ class VnfBaseTesting(unittest.TestCase):
self.test.project = "functest"
self.test.start_time = "1"
self.test.stop_time = "5"
- self.test.criteria = ""
+ self.test.result = ""
self.test.details = {"orchestrator": {"status": "PASS",
"result": "",
"duration": 20},
diff --git a/functest/tests/unit/odl/test_odl.py b/functest/tests/unit/odl/test_odl.py
index 55e100dd..80469346 100644
--- a/functest/tests/unit/odl/test_odl.py
+++ b/functest/tests/unit/odl/test_odl.py
@@ -123,7 +123,7 @@ class ODLParseResultTesting(ODLTesting):
with mock.patch('robot.api.ExecutionResult',
return_value=mock.Mock(suite=suite)):
self.test.parse_results()
- self.assertEqual(self.test.criteria, config['status'])
+ self.assertEqual(self.test.result, config['status'])
self.assertEqual(self.test.start_time,
timestamp_to_secs(config['starttime']))
self.assertEqual(self.test.stop_time,
diff --git a/functest/tests/unit/utils/test_functest_utils.py b/functest/tests/unit/utils/test_functest_utils.py
index 22cadf0f..7ab8b455 100644
--- a/functest/tests/unit/utils/test_functest_utils.py
+++ b/functest/tests/unit/utils/test_functest_utils.py
@@ -43,6 +43,7 @@ class FunctestUtilsTesting(unittest.TestCase):
self.db_url = 'test_db_url'
self.success_rate = 2.0
self.criteria = 'test_criteria==2.0'
+ self.result = 'PASS'
self.start_date = 1482624000
self.stop_date = 1482624000
self.start_time = time.time()
@@ -279,7 +280,7 @@ class FunctestUtilsTesting(unittest.TestCase):
as mock_logger_error:
functest_utils.push_results_to_db(self.project, self.case_name,
self.start_date, self.stop_date,
- self.criteria, self.details)
+ self.result, self.details)
mock_logger_error.assert_called_once_with("Please set env var: " +
str("\'" + env_var +
"\'"))
@@ -311,7 +312,7 @@ class FunctestUtilsTesting(unittest.TestCase):
push_results_to_db(self.project, self.case_name,
self.start_date,
self.stop_date,
- self.criteria, self.details))
+ self.result, self.details))
mock_logger_error.assert_called_once_with(test_utils.
RegexMatch("Pushing "
"Result to"
@@ -334,7 +335,7 @@ class FunctestUtilsTesting(unittest.TestCase):
push_results_to_db(self.project, self.case_name,
self.start_date,
self.stop_date,
- self.criteria, self.details))
+ self.result, self.details))
self.assertTrue(mock_logger_error.called)
def test_push_results_to_db_default(self):
@@ -349,7 +350,7 @@ class FunctestUtilsTesting(unittest.TestCase):
push_results_to_db(self.project, self.case_name,
self.start_date,
self.stop_date,
- self.criteria, self.details))
+ self.result, self.details))
readline = 0
test_ip = ['10.1.23.4', '10.1.14.15', '10.1.16.15']