Exemplo n.º 1
0
 def test_set_perms_failure(self):
     self.mox.StubOutWithMock(openvz_conn.utils, 'execute')
     openvz_conn.utils.execute('chmod', 755, TEMPFILE, run_as_root=True)\
                               .AndRaise(exception.ProcessExecutionError)
     self.mox.ReplayAll()
     fh = openvz_conn.OVZFile(TEMPFILE)
     self.assertRaises(exception.Error, fh.set_permissions, 755)
Exemplo n.º 2
0
 def test_make_directory_failure(self):
     self.mox.StubOutWithMock(openvz_conn.utils, 'execute')
     openvz_conn.utils.execute('mkdir', '-p', TEMPFILE, run_as_root=True)\
                               .AndRaise(exception.ProcessExecutionError)
     self.mox.ReplayAll()
     fh = openvz_conn.OVZFile(TEMPFILE)
     self.assertRaises(exception.Error, fh.make_dir, TEMPFILE)
Exemplo n.º 3
0
 def test_set_perms_success(self):
     self.mox.StubOutWithMock(openvz_conn.utils, 'execute')
     openvz_conn.utils.execute('chmod', 755, TEMPFILE, run_as_root=True)\
                               .AndReturn(('', ''))
     self.mox.ReplayAll()
     fh = openvz_conn.OVZFile(TEMPFILE)
     fh.set_permissions(755)
Exemplo n.º 4
0
 def test_make_directory_success(self):
     self.mox.StubOutWithMock(openvz_conn.utils, 'execute')
     openvz_conn.utils.execute('mkdir', '-p', TEMPFILE, run_as_root=True) \
                              .AndReturn(('', ''))
     self.mox.ReplayAll()
     fh = openvz_conn.OVZFile(TEMPFILE)
     fh.make_dir(TEMPFILE)
Exemplo n.º 5
0
 def test_touch_file_failure(self):
     fh = openvz_conn.OVZFile(TEMPFILE)
     self.mox.StubOutWithMock(fh, 'make_path')
     fh.make_path()
     self.mox.StubOutWithMock(openvz_conn.utils, 'execute')
     openvz_conn.utils.execute('touch', TEMPFILE, run_as_root=True)\
                               .AndRaise(exception.ProcessExecutionError)
     self.mox.ReplayAll()
     self.assertRaises(exception.Error, fh.touch)
Exemplo n.º 6
0
 def test_touch_file_success(self):
     fh = openvz_conn.OVZFile(TEMPFILE)
     self.mox.StubOutWithMock(fh, 'make_path')
     fh.make_path()
     self.mox.StubOutWithMock(openvz_conn.utils, 'execute')
     openvz_conn.utils.execute('touch', TEMPFILE, run_as_root=True)\
                               .AndReturn(('', ''))
     self.mox.ReplayAll()
     fh.touch()
Exemplo n.º 7
0
 def test_write_to_file_failure(self):
     self.mox.StubOutWithMock(__builtin__, 'open')
     __builtin__.open(mox.IgnoreArg(), 'w').AndRaise(exception.Error)
     self.mox.ReplayAll()
     fh = openvz_conn.OVZFile(TEMPFILE)
     self.assertRaises(exception.Error, fh.write)
Exemplo n.º 8
0
 def test_write_to_file_success(self):
     self.mox.StubOutWithMock(__builtin__, 'open')
     __builtin__.open(mox.IgnoreArg(), 'w').AndReturn(self.fake_file)
     self.mox.ReplayAll()
     fh = openvz_conn.OVZFile(TEMPFILE)
     fh.write()