Statistics
| Branch: | Tag: | Revision:

root / test / py / cmdlib / instance_query_unittest.py @ 2f3230f6

History | View | Annotate | Download (1.9 kB)

1
#!/usr/bin/python
2
#
3

    
4
# Copyright (C) 2013 Google Inc.
5
#
6
# This program is free software; you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; either version 2 of the License, or
9
# (at your option) any later version.
10
#
11
# This program is distributed in the hope that it will be useful, but
12
# WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
# General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License
17
# along with this program; if not, write to the Free Software
18
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19
# 02110-1301, USA.
20

    
21

    
22
"""Tests for LUInstanceFailover and LUInstanceMigrate
23

24
"""
25

    
26
from ganeti import opcodes
27
from ganeti import query
28

    
29
from testsupport import *
30

    
31
import testutils
32

    
33

    
34
class TestLUInstanceQuery(CmdlibTestCase):
35
  def setUp(self):
36
    super(TestLUInstanceQuery, self).setUp()
37

    
38
    self.inst = self.cfg.AddNewInstance()
39
    self.fields = query._BuildInstanceFields().keys()
40

    
41
  def testInvalidInstance(self):
42
    op = opcodes.OpInstanceQuery(names=["does_not_exist"],
43
                                 output_fields=self.fields)
44
    self.ExecOpCodeExpectOpPrereqError(
45
      op, "Instance 'does_not_exist' not known")
46

    
47
  def testQueryInstance(self):
48
    op = opcodes.OpInstanceQuery(output_fields=self.fields)
49
    self.ExecOpCode(op)
50

    
51

    
52
class TestLUInstanceQueryData(CmdlibTestCase):
53
  def setUp(self):
54
    super(TestLUInstanceQueryData, self).setUp()
55

    
56
    self.inst = self.cfg.AddNewInstance()
57

    
58
  def testQueryInstanceData(self):
59
    op = opcodes.OpInstanceQueryData()
60
    self.ExecOpCode(op)
61

    
62
  def testQueryStaticInstanceData(self):
63
    op = opcodes.OpInstanceQueryData(static=True)
64
    self.ExecOpCode(op)
65

    
66

    
67
if __name__ == "__main__":
68
  testutils.GanetiTestProgram()