summaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
authorThiago da Silva <thiago@redhat.com>2014-04-12 12:40:44 -0400
committerThiago da Silva <thiago@redhat.com>2015-02-20 12:53:06 -0500
commit88bc71ff92026d889125bc0c4b14b450e41e62c4 (patch)
tree32576f33f0965fa790f8990afbbbd6c22ef8056b /test/unit
parentfc318e921b073cdbe9fbe62b8c893634b057f0e8 (diff)
Added option to read whole file
Added option to read whole file if caller send -1 as the buflen to read function. Also added a copy of getsize to File class, now called fgetsize, which returns the size of the file as reported by fstat Removed flags paramater from read function as it is never used by libgfapi. Change-Id: Ia1c04ef9717d9ca098e1961300d6ee216381c989 Signed-off-by: Thiago da Silva <thiago@redhat.com> Signed-off-by: Prashanth Pai <ppai@redhat.com>
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/gluster/test_gfapi.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/unit/gluster/test_gfapi.py b/test/unit/gluster/test_gfapi.py
index 1608332..0d73a32 100644
--- a/test/unit/gluster/test_gfapi.py
+++ b/test/unit/gluster/test_gfapi.py
@@ -180,6 +180,18 @@ class TestFile(unittest.TestCase):
b = self.fd.read(5)
self.assertEqual(b, 0)
+ def test_read_buflen_negative(self):
+ _mock_fgetsize = Mock(return_value=12345)
+
+ def _mock_glfs_read(fd, rbuf, buflen, flags):
+ self.assertEqual(buflen, 12345)
+ return buflen
+
+ for buflen in (-1,-2,-999):
+ with patch("glusterfs.gfapi.api.glfs_read", _mock_glfs_read):
+ with patch("glusterfs.gfapi.File.fgetsize", _mock_fgetsize):
+ b = self.fd.read(buflen)
+
def test_write_success(self):
mock_glfs_write = Mock()
mock_glfs_write.return_value = 5