Revision 64a66bd2
b/test/py/ganeti.hypervisor.hv_xen_unittest.py | ||
---|---|---|
23 | 23 |
|
24 | 24 |
import string # pylint: disable=W0402 |
25 | 25 |
import unittest |
26 |
import tempfile |
|
27 |
import shutil |
|
26 | 28 |
|
27 | 29 |
from ganeti import constants |
28 | 30 |
from ganeti import objects |
... | ... | |
298 | 300 |
self.assertRaises(errors.ProgrammerError, hv._RunXen, []) |
299 | 301 |
|
300 | 302 |
|
303 |
class TestXenHypervisorWriteConfigFile(unittest.TestCase): |
|
304 |
def setUp(self): |
|
305 |
self.tmpdir = tempfile.mkdtemp() |
|
306 |
|
|
307 |
def tearDown(self): |
|
308 |
shutil.rmtree(self.tmpdir) |
|
309 |
|
|
310 |
def testWriteError(self): |
|
311 |
cfgdir = utils.PathJoin(self.tmpdir, "foobar") |
|
312 |
|
|
313 |
hv = hv_xen.XenHypervisor(_cfgdir=cfgdir, |
|
314 |
_run_cmd_fn=NotImplemented, |
|
315 |
_cmd=NotImplemented) |
|
316 |
|
|
317 |
self.assertFalse(os.path.exists(cfgdir)) |
|
318 |
|
|
319 |
try: |
|
320 |
hv._WriteConfigFile("name", "data") |
|
321 |
except errors.HypervisorError, err: |
|
322 |
self.assertTrue(str(err).startswith("Cannot write Xen instance")) |
|
323 |
else: |
|
324 |
self.fail("Exception was not raised") |
|
325 |
|
|
326 |
|
|
301 | 327 |
if __name__ == "__main__": |
302 | 328 |
testutils.GanetiTestProgram() |
Also available in: Unified diff