Lin Yang 6e9aeaaa00 Return new composed node ID
It should return new composed node ID to user, since this is the
only chance for user to get it.

Change-Id: I519111febf5e326f6fa9919472e49e9e04c96f02
2017-08-17 17:45:47 -07:00

47 lines
1.7 KiB
Python

# Copyright 2017 Intel, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
import mock
import testtools
from rsdclient.v1 import node
class ClusterManagerTest(testtools.TestCase):
def setUp(self):
super(ClusterManagerTest, self).setUp()
self.client = mock.Mock()
self.client._nodes_path = '/redfish/v1/Nodes'
self.mgr = node.NodeManager(self.client)
def test_compose_node(self):
mock_node_collection = mock.Mock()
mock_node_collection.compose_node.return_value = '/redfish/v1/Nodes/1'
self.client.get_node_collection.return_value = mock_node_collection
result = self.mgr.compose({'Name': 'fake_name'})
self.mgr.client.get_node_collection.assert_called_once()
mock_node_collection.compose_node.assert_called_once_with(
{'Name': 'fake_name'})
self.assertEqual(result, '1')
def test_delete_node(self):
node_id = '1'
mock_node = mock.Mock()
self.client.get_node.return_value = mock_node
self.mgr.delete(node_id)
self.mgr.client.get_node.assert_called_once_with('/redfish/v1/Nodes/1')
mock_node.delete_node.assert_called_once()