diff options
author | Thiago da Silva <thiago@redhat.com> | 2014-03-26 16:31:28 -0400 |
---|---|---|
committer | Thiago da Silva <thiago@redhat.com> | 2014-03-27 15:21:50 -0400 |
commit | bd683d93cb8d967f761d53f7a6b4243eb8eaedea (patch) | |
tree | 5f73d7390690a9de7e3bf2371fb6590d5ecce95b /test/unit/gluster/test_gfapi.py | |
parent | f50cec44586e851c3d9e29dd59574696ae6f0c3a (diff) |
adding new apis requested from gluster-swift proj
This patch adds new functions that are used in gluster-swift.
These functions are: dup, lseek, getatime, getctime, getmtime
Change-Id: I09036f7e393a89e09913f7f6de173e1eca8dca95
Signed-off-by: Thiago da Silva <thiago@redhat.com>
Diffstat (limited to 'test/unit/gluster/test_gfapi.py')
-rw-r--r-- | test/unit/gluster/test_gfapi.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/test/unit/gluster/test_gfapi.py b/test/unit/gluster/test_gfapi.py index ed7ed45..e0308f7 100644 --- a/test/unit/gluster/test_gfapi.py +++ b/test/unit/gluster/test_gfapi.py @@ -49,7 +49,7 @@ class TestFile(unittest.TestCase): @classmethod def setUpClass(cls): - cls.fd = gfapi.File(2) + cls.fd = gfapi.File(2, 'fakefile') @classmethod def tearDownClass(cls): @@ -77,6 +77,16 @@ class TestFile(unittest.TestCase): with patch("glusterfs.gfapi.api.glfs_fchown", mock_glfs_fchown): self.assertRaises(OSError, self.fd.fchown, 9, 11) + def test_dup(self): + mock_glfs_dup = Mock() + mock_glfs_dup.return_value = 2 + + with patch("glusterfs.gfapi.api.glfs_dup", mock_glfs_dup): + f = self.fd.dup() + self.assertTrue(isinstance(f, gfapi.File)) + self.assertEqual(f.originalpath, "fakefile") + self.assertEqual(f.fd, 2) + def test_fdatasync_success(self): mock_glfs_fdatasync = Mock() mock_glfs_fdatasync.return_value = 4 @@ -122,6 +132,14 @@ class TestFile(unittest.TestCase): with patch("glusterfs.gfapi.api.glfs_fsync", mock_glfs_fsync): self.assertRaises(OSError, self.fd.fsync) + def test_lseek_success(self): + mock_glfs_lseek = Mock() + mock_glfs_lseek.return_value = 20 + + with patch("glusterfs.gfapi.api.glfs_lseek", mock_glfs_lseek): + o = self.fd.lseek(20, os.SEEK_SET) + self.assertEqual(o, 20) + def test_read_success(self): def _mock_glfs_read(fd, rbuf, buflen, flags): rbuf.value = "hello" |