Merge "[docs] Remove the VTC chapter in the userguide"
[yardstick.git] / yardstick / tests / unit / benchmark / scenarios / lib / test_check_value.py
1 ##############################################################################
2 # Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
3 #
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9 import unittest
10
11 from yardstick.benchmark.scenarios.lib import check_value
12 from yardstick.common import exceptions as y_exc
13
14
15 class CheckValueTestCase(unittest.TestCase):
16
17     def test_eq_pass(self):
18         scenario_cfg = {'options': {'operator': 'eq',
19                                     'value1': 1,
20                                     'value2': 1}}
21         obj = check_value.CheckValue(scenario_cfg, {})
22         result = obj.run({})
23
24         self.assertEqual({}, result)
25
26     def test_ne_pass(self):
27         scenario_cfg = {'options': {'operator': 'ne',
28                                     'value1': 1,
29                                     'value2': 2}}
30         obj = check_value.CheckValue(scenario_cfg, {})
31         result = obj.run({})
32
33         self.assertEqual({}, result)
34
35     def test_result(self):
36         scenario_cfg = {'options': {'operator': 'eq',
37                                     'value1': 1,
38                                     'value2': 1},
39                         'output': 'foo'}
40         obj = check_value.CheckValue(scenario_cfg, {})
41         result = obj.run({})
42
43         self.assertDictEqual(result, {'foo': 'PASS'})
44
45     def test_eq(self):
46         scenario_cfg = {'options': {'operator': 'eq',
47                                     'value1': 1,
48                                     'value2': 2}}
49         obj = check_value.CheckValue(scenario_cfg, {})
50
51         with self.assertRaises(y_exc.ValueCheckError):
52             result = obj.run({})
53             self.assertEqual({}, result)
54
55     def test_ne(self):
56         scenario_cfg = {'options': {'operator': 'ne',
57                                     'value1': 1,
58                                     'value2': 1}}
59         obj = check_value.CheckValue(scenario_cfg, {})
60
61         with self.assertRaises(y_exc.ValueCheckError):
62             result = obj.run({})
63             self.assertEqual({}, result)