Revision ebeb600f test/ganeti.rapi.rlib2_unittest.py

b/test/ganeti.rapi.rlib2_unittest.py
180 180
        self.assertRaises(http.HttpBadRequest, self.Parse, data, False)
181 181

  
182 182

  
183
class TestParseExportInstanceRequest(testutils.GanetiTestCase):
184
  def setUp(self):
185
    testutils.GanetiTestCase.setUp(self)
186

  
187
    self.Parse = rlib2._ParseExportInstanceRequest
188

  
189
  def test(self):
190
    name = "instmoo"
191
    data = {
192
      "mode": constants.EXPORT_MODE_REMOTE,
193
      "destination": [(1, 2, 3), (99, 99, 99)],
194
      "shutdown": True,
195
      "remove_instance": True,
196
      "x509_key_name": ("name", "hash"),
197
      "destination_x509_ca": ("x", "y", "z"),
198
      }
199
    op = self.Parse(name, data)
200
    self.assert_(isinstance(op, opcodes.OpExportInstance))
201
    self.assertEqual(op.instance_name, name)
202
    self.assertEqual(op.mode, constants.EXPORT_MODE_REMOTE)
203
    self.assertEqual(op.shutdown, True)
204
    self.assertEqual(op.remove_instance, True)
205
    self.assertEqualValues(op.x509_key_name, ("name", "hash"))
206
    self.assertEqualValues(op.destination_x509_ca, ("x", "y", "z"))
207

  
208
  def testDefaults(self):
209
    name = "inst1"
210
    data = {
211
      "destination": "node2",
212
      "shutdown": False,
213
      }
214
    op = self.Parse(name, data)
215
    self.assert_(isinstance(op, opcodes.OpExportInstance))
216
    self.assertEqual(op.instance_name, name)
217
    self.assertEqual(op.mode, constants.EXPORT_MODE_LOCAL)
218
    self.assertEqual(op.remove_instance, False)
219

  
220
  def testErrors(self):
221
    self.assertRaises(http.HttpBadRequest, self.Parse, "err1",
222
                      { "remove_instance": "True", })
223
    self.assertRaises(http.HttpBadRequest, self.Parse, "err1",
224
                      { "remove_instance": "False", })
225

  
226

  
183 227
if __name__ == '__main__':
184 228
  testutils.GanetiTestProgram()

Also available in: Unified diff