diff options
| author | Prashanth Pai <ppai@redhat.com> | 2015-06-23 20:04:30 +0530 | 
|---|---|---|
| committer | Prashanth Pai <ppai@redhat.com> | 2016-02-24 11:16:57 +0530 | 
| commit | 14c16992b563a77330478bcc6fecdb54df4300b5 (patch) | |
| tree | a21195304749786c8564fb4339ac7c3120fbb9d1 /test/unit | |
| parent | 6df97fd49fa9be6394bd066c6c64fd7c06959a77 (diff) | |
Add readinto() API
readinto()
This method is useful when you have to read a large file over multiple
read calls. While read() allocates a buffer every time it's invoked,
readinto() copies data to an already allocated buffer passed to it.
Change-Id: Ic8a3aa0e544e09e05101c983b329c91864832e4a
Signed-off-by: Prashanth Pai <ppai@redhat.com>
Diffstat (limited to 'test/unit')
| -rw-r--r-- | test/unit/gluster/test_gfapi.py | 11 | 
1 files changed, 11 insertions, 0 deletions
diff --git a/test/unit/gluster/test_gfapi.py b/test/unit/gluster/test_gfapi.py index 5551235..4be2346 100644 --- a/test/unit/gluster/test_gfapi.py +++ b/test/unit/gluster/test_gfapi.py @@ -192,6 +192,17 @@ class TestFile(unittest.TestCase):                  with patch("gluster.gfapi.File.fgetsize", _mock_fgetsize):                      self.fd.read(buflen) +    def test_readinto(self): +        mock_glfs_read = Mock() +        mock_glfs_read.return_value = 5 + +        with patch("gluster.gfapi.api.glfs_read", mock_glfs_read): +            buf = bytearray(10) +            ret = self.fd.readinto(buf) +            self.assertEqual(ret, 5) + +        self.assertRaises(TypeError, self.fd.readinto, str("hello")) +      def test_write_success(self):          mock_glfs_write = Mock()          mock_glfs_write.return_value = 5  | 
