Commit 19830e88 authored by Thomas Thrainer's avatar Thomas Thrainer
Browse files

Add unit test for LUClusterActivateMasterIp



In order to properly assert the called RPC method, __eq__ is implemented
on ConfigObject as well.
Signed-off-by: default avatarThomas Thrainer <thomasth@google.com>
Reviewed-by: default avatarMichele Tartara <mtartara@google.com>
parent e969a81f
......@@ -1238,6 +1238,7 @@ TEST_FILES = \
python_tests = \
doc/examples/rapi_testutils.py \
test/py/cmdlib/cluster_unittest.py \
test/py/cmdlib/test_unittest.py \
test/py/cfgupgrade_unittest.py \
test/py/docs_unittest.py \
......
......@@ -266,6 +266,10 @@ class ConfigObject(outils.ValidatedSlots):
"""Implement __repr__ for ConfigObjects."""
return repr(self.ToDict())
def __eq__(self, other):
"""Implement __eq__ for ConfigObjects."""
return isinstance(other, self.__class__) and self.ToDict() == other.ToDict()
def UpgradeConfig(self):
"""Fill defaults for missing configuration values.
......
#!/usr/bin/python
#
# Copyright (C) 2013 Google Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
"""Tests for LUCluster*
"""
from ganeti import opcodes
from testsupport import *
import testutils
class TestLUClusterActivateMasterIp(CmdlibTestCase):
def testSuccess(self):
op = opcodes.OpClusterActivateMasterIp()
self.rpc.call_node_activate_master_ip.return_value = \
RpcResultsBuilder(cfg=self.cfg) \
.CreateSuccessfulNodeResult(self.cfg.GetMasterNode())
self.ExecOpCode(op)
self.rpc.call_node_activate_master_ip.assert_called_once_with(
self.cfg.GetMasterNode(),
self.cfg.GetMasterNetworkParameters(),
False)
def testFailure(self):
op = opcodes.OpClusterActivateMasterIp()
self.rpc.call_node_activate_master_ip.return_value = \
RpcResultsBuilder(cfg=self.cfg) \
.CreateFailedNodeResult(self.cfg.GetMasterNode()) \
self.ExecOpCodeExpectOpExecError(op)
if __name__ == "__main__":
testutils.GanetiTestProgram()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment