Move tests: unit/benchmark
[yardstick.git] / yardstick / tests / unit / benchmark / scenarios / lib / test_add_memory_load.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 import mock
11
12 from yardstick.benchmark.scenarios.lib.add_memory_load import AddMemoryLoad
13
14
15 class AddMemoryLoadTestCase(unittest.TestCase):
16
17     @mock.patch('yardstick.ssh.SSH.from_node')
18     def test_add_memory_load_with_load(self, mock_from_node):
19         scenario_cfg = {
20             'options': {
21                 'memory_load': 0.5
22             }
23         }
24         context_cfg = {
25             'host': {}
26         }
27         mock_from_node().execute.return_value = (0, '0 2048 512', '')
28         obj = AddMemoryLoad(scenario_cfg, context_cfg)
29         obj.run({})
30         self.assertTrue(mock_from_node.called)
31
32     @mock.patch('yardstick.ssh.SSH.from_node')
33     def test_add_memory_load_without_load(self, mock_from_node):
34         scenario_cfg = {
35             'options': {
36                 'memory_load': 0
37             }
38         }
39         context_cfg = {
40             'host': {}
41         }
42         obj = AddMemoryLoad(scenario_cfg, context_cfg)
43         obj.run({})
44         self.assertTrue(mock_from_node.called)
45
46     @mock.patch('yardstick.ssh.SSH.from_node')
47     def test_add_memory_load_without_args(self, mock_from_node):
48         scenario_cfg = {
49             'options': {
50             }
51         }
52         context_cfg = {
53             'host': {}
54         }
55         obj = AddMemoryLoad(scenario_cfg, context_cfg)
56         obj.run({})
57         self.assertTrue(mock_from_node.called)
58
59
60 def main():
61     unittest.main()
62
63
64 if __name__ == '__main__':
65     main()