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)
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)
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()
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()
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()
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()
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))
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)
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)