Merge "Rename daily test suite files to match slave names on Jenkins"
[yardstick.git] / tests / unit / cmd / commands / test_task.py
1 #!/usr/bin/env python
2
3 ##############################################################################
4 # Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
5 #
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Apache License, Version 2.0
8 # which accompanies this distribution, and is available at
9 # http://www.apache.org/licenses/LICENSE-2.0
10 ##############################################################################
11
12 # Unittest for yardstick.cmd.commands.task
13
14 import mock
15 import unittest
16
17 from yardstick.cmd.commands import task
18
19
20 class TaskCommandsTestCase(unittest.TestCase):
21
22     @mock.patch('yardstick.cmd.commands.task.Context')
23     def test_parse_nodes_host_target_same_context(self, mock_context):
24         nodes = {
25             "host": "node1.LF",
26             "target": "node2.LF"
27         }
28         scenario_cfg = {"nodes": nodes}
29         server_info = {
30            "ip": "10.20.0.3",
31            "user": "root",
32            "key_filename": "/root/.ssh/id_rsa"
33         }
34         mock_context.get_server.return_value = server_info
35         context_cfg = task.parse_nodes_with_context(scenario_cfg)
36
37         self.assertEqual(context_cfg["host"], server_info)
38         self.assertEqual(context_cfg["target"], server_info)