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