Commit 2f3230f6 authored by Thomas Thrainer's avatar Thomas Thrainer
Browse files

Add unit test for LUInstanceQuery and -QueryData



This patch provides rudimentary unit test coverage for LUInstanceQuery
and LUInstanceQueryData.
Signed-off-by: default avatarThomas Thrainer <thomasth@google.com>
Reviewed-by: default avatarKlaus Aehlig <aehlig@google.com>
parent d1b2ffe8
......@@ -1322,6 +1322,7 @@ python_tests = \
test/py/cmdlib/group_unittest.py \
test/py/cmdlib/instance_unittest.py \
test/py/cmdlib/instance_migration_unittest.py \
test/py/cmdlib/instance_query_unittest.py \
test/py/cmdlib/instance_storage_unittest.py \
test/py/cmdlib/test_unittest.py \
test/py/cfgupgrade_unittest.py \
......
#!/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 LUInstanceFailover and LUInstanceMigrate
"""
from ganeti import opcodes
from ganeti import query
from testsupport import *
import testutils
class TestLUInstanceQuery(CmdlibTestCase):
def setUp(self):
super(TestLUInstanceQuery, self).setUp()
self.inst = self.cfg.AddNewInstance()
self.fields = query._BuildInstanceFields().keys()
def testInvalidInstance(self):
op = opcodes.OpInstanceQuery(names=["does_not_exist"],
output_fields=self.fields)
self.ExecOpCodeExpectOpPrereqError(
op, "Instance 'does_not_exist' not known")
def testQueryInstance(self):
op = opcodes.OpInstanceQuery(output_fields=self.fields)
self.ExecOpCode(op)
class TestLUInstanceQueryData(CmdlibTestCase):
def setUp(self):
super(TestLUInstanceQueryData, self).setUp()
self.inst = self.cfg.AddNewInstance()
def testQueryInstanceData(self):
op = opcodes.OpInstanceQueryData()
self.ExecOpCode(op)
def testQueryStaticInstanceData(self):
op = opcodes.OpInstanceQueryData(static=True)
self.ExecOpCode(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