Esempio n. 1
0
 def test_write_to_file_success(self):
     filehandle = FakeFile(file_contents)
     self.mox.StubOutWithMock(openvz_conn, 'open')
     openvz_conn.open('/tmp/foo', 'w').AndReturn(filehandle)
     self.mox.ReplayAll()
     conn = openvz_conn.OpenVzConnection(False)
     conn._write_to_file('/tmp/foo', file_contents)
Esempio n. 2
0
 def test_write_to_file_failure(self):
     self.mox.StubOutWithMock(openvz_conn, 'open')
     openvz_conn.open('/tmp/foo', 'w').AndRaise(Exception)
     self.mox.ReplayAll()
     conn = openvz_conn.OpenVzConnection(False)
     self.assertRaises(exception.Error, conn._write_to_file,
                       '/tmp/foo', file_contents)
Esempio n. 3
0
 def test_write_to_file_success(self):
     filehandle = FakeFile(file_contents)
     self.mox.StubOutWithMock(openvz_conn, 'open')
     openvz_conn.open('/tmp/foo', 'w').AndReturn(filehandle)
     self.mox.ReplayAll()
     fh = openvz_conn.OVZFile('/tmp/foo')
     fh.write()
Esempio n. 4
0
 def test_read_file_success(self):
     file_contents = FakeFile(file_contents)
     self.mox.StubOutWithMock(openvz_conn, 'open')
     openvz_conn.open('/tmp/foo', 'r').AndReturn(file_contents)
     self.mox.ReplayAll()
     fh = openvz_conn.OVZFile('/tmp/foo')
     fh.read()
Esempio n. 5
0
 def test_write_to_file_success(self):
     filehandle = FakeFile(file_contents)
     self.mox.StubOutWithMock(openvz_conn, "open")
     openvz_conn.open("/tmp/foo", "w").AndReturn(filehandle)
     self.mox.ReplayAll()
     fh = openvz_conn.OVZFile("/tmp/foo")
     fh.write()
Esempio n. 6
0
 def test_read_file_success(self):
     file_contents = FakeFile(file_contents)
     self.mox.StubOutWithMock(openvz_conn, "open")
     openvz_conn.open("/tmp/foo", "r").AndReturn(file_contents)
     self.mox.ReplayAll()
     fh = openvz_conn.OVZFile("/tmp/foo")
     fh.read()
Esempio n. 7
0
 def test_read_file_success(self):
     file_contents = FakeFile(file_contents)
     self.mox.StubOutWithMock(openvz_conn, 'open')
     openvz_conn.open('/tmp/foo', 'r').AndReturn(file_contents)
     self.mox.ReplayAll()
     conn = openvz_conn.OpenVzConnection(False)
     resp = conn._read_file('/tmp/foo')
     self.assertTrue(isinstance(resp, list))
Esempio n. 8
0
 def test_write_to_file_failure(self):
     self.mox.StubOutWithMock(openvz_conn, 'open')
     openvz_conn.open('/tmp/foo', 'w').AndRaise(Exception)
     self.mox.ReplayAll()
     fh = openvz_conn.OVZFile('/tmp/foo')
     self.assertRaises(exception.Error, fh.write)
Esempio n. 9
0
 def test_write_to_file_failure(self):
     self.mox.StubOutWithMock(openvz_conn, "open")
     openvz_conn.open("/tmp/foo", "w").AndRaise(Exception)
     self.mox.ReplayAll()
     fh = openvz_conn.OVZFile("/tmp/foo")
     self.assertRaises(exception.Error, fh.write)