aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/benchmark/scenarios/availability/test_baseresultchecker.py
diff options
context:
space:
mode:
authorlihuan <lihuansse@tongji.edu.cn>2016-07-05 20:40:10 +0800
committerlihuan <lihuansse@tongji.edu.cn>2016-07-06 16:58:00 +0800
commit1d6b2af637b06f815248003d85e0352512c9b374 (patch)
treea4294ede870c2a764778795d72bbd26b831be5af /tests/unit/benchmark/scenarios/availability/test_baseresultchecker.py
parenteacef205efa9289bccbf38d82df07cdc63486d35 (diff)
Creating result checker classes
JIRA: YARDSTICK-276 Change-Id: I63c4f2c36108e95f5d3b7da42e66cb8c9b16c817 Signed-off-by: lihuan <lihuansse@tongji.edu.cn>
Diffstat (limited to 'tests/unit/benchmark/scenarios/availability/test_baseresultchecker.py')
-rw-r--r--tests/unit/benchmark/scenarios/availability/test_baseresultchecker.py88
1 files changed, 88 insertions, 0 deletions
diff --git a/tests/unit/benchmark/scenarios/availability/test_baseresultchecker.py b/tests/unit/benchmark/scenarios/availability/test_baseresultchecker.py
new file mode 100644
index 000000000..9972d6b1b
--- /dev/null
+++ b/tests/unit/benchmark/scenarios/availability/test_baseresultchecker.py
@@ -0,0 +1,88 @@
+#!/usr/bin/env python
+
+##############################################################################
+# Copyright (c) 2016 Huan Li and others
+# lihuansse@tongji.edu.cn
+# 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
+##############################################################################
+
+# Unittest for yardstick.benchmark.scenarios.availability.result_checker
+# .baseresultchecker
+
+import mock
+import unittest
+
+from yardstick.benchmark.scenarios.availability.result_checker import baseresultchecker
+
+
+@mock.patch('yardstick.benchmark.scenarios.availability.result_checker'
+ '.baseresultchecker.BaseResultChecker')
+class ResultCheckerMgrTestCase(unittest.TestCase):
+
+ def setUp(self):
+ config = {
+ 'checker_type': 'general-result-checker',
+ 'key' : 'process-checker'
+ }
+
+ self.checker_configs = []
+ self.checker_configs.append(config)
+
+ def test_ResultCheckerMgr_setup_successful(self, mock_basechacer):
+ mgr_ins = baseresultchecker.ResultCheckerMgr()
+ mgr_ins.init_ResultChecker(self.checker_configs, None)
+ mgr_ins.verify()
+
+ def test_getitem_succeessful(self, mock_basechacer):
+ mgr_ins = baseresultchecker.ResultCheckerMgr()
+ mgr_ins.init_ResultChecker(self.checker_configs, None)
+ checker_ins = mgr_ins["process-checker"]
+
+ def test_getitem_fail(self, mock_basechacer):
+ mgr_ins = baseresultchecker.ResultCheckerMgr()
+ mgr_ins.init_ResultChecker(self.checker_configs, None)
+ with self.assertRaises(KeyError):
+ checker_ins = mgr_ins["checker-not-exist"]
+
+
+class BaseResultCheckerTestCase(unittest.TestCase):
+
+ class ResultCheckeSimple(baseresultchecker.BaseResultChecker):
+ __result_checker__type__ = "ResultCheckeForTest"
+ def setup(self):
+ self.success = False
+
+ def verify(self):
+ return self.success
+
+ def setUp(self):
+ self.checker_cfg = {
+ 'checker_type': 'general-result-checker',
+ 'key' : 'process-checker'
+ }
+
+ def test_baseresultchecker_setup_verify_successful(self):
+ ins = baseresultchecker.BaseResultChecker(self.checker_cfg, None)
+ ins.setup()
+ ins.verify()
+
+ def test_baseresultchecker_verfiy_pass(self):
+ ins = baseresultchecker.BaseResultChecker(self.checker_cfg, None)
+ ins.setup()
+ ins.actualResult = True
+ ins.expectedResult = True
+ ins.verify()
+
+ def test_get_script_fullpath(self):
+ ins = baseresultchecker.BaseResultChecker(self.checker_cfg, None)
+ path = ins.get_script_fullpath("test.bash")
+
+ def test_get_resultchecker_cls_successful(self):
+ baseresultchecker.BaseResultChecker.get_resultchecker_cls("ResultCheckeForTest")
+
+ def test_get_resultchecker_cls_fail(self):
+ with self.assertRaises(RuntimeError):
+ baseresultchecker.BaseResultChecker.get_resultchecker_cls("ResultCheckeNotExist")