diff options
Diffstat (limited to 'test/unit/gluster/test_gfapi.py')
-rw-r--r-- | test/unit/gluster/test_gfapi.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/unit/gluster/test_gfapi.py b/test/unit/gluster/test_gfapi.py index 550ba79..1608332 100644 --- a/test/unit/gluster/test_gfapi.py +++ b/test/unit/gluster/test_gfapi.py @@ -63,6 +63,21 @@ class TestFile(unittest.TestCase): def tearDown(self): glusterfs.gfapi.api.glfs_close = self._saved_glfs_close + def test_fchmod_success(self): + mock_glfs_fchmod = Mock() + mock_glfs_fchmod.return_value = 0 + + with patch("glusterfs.gfapi.api.glfs_fchmod", mock_glfs_fchmod): + ret = self.fd.fchmod(0600) + self.assertEquals(ret, 0) + + def test_fchmod_fail_exception(self): + mock_glfs_fchmod = Mock() + mock_glfs_fchmod.return_value = -1 + + with patch("glusterfs.gfapi.api.glfs_fchmod", mock_glfs_fchmod): + self.assertRaises(OSError, self.fd.fchmod, 0600) + def test_fchown_success(self): mock_glfs_fchown = Mock() mock_glfs_fchown.return_value = 0 @@ -278,6 +293,21 @@ class TestVolume(unittest.TestCase): glusterfs.gfapi.api.glfs_close = cls._saved_glfs_close glusterfs.gfapi.api.glfs_closedir = cls._saved_glfs_closedir + def test_chmod_success(self): + mock_glfs_chmod = Mock() + mock_glfs_chmod.return_value = 0 + + with patch("glusterfs.gfapi.api.glfs_chmod", mock_glfs_chmod): + ret = self.vol.chmod("file.txt", 0600) + self.assertEquals(ret, 0) + + def test_chmod_fail_exception(self): + mock_glfs_chmod = Mock() + mock_glfs_chmod.return_value = -1 + + with patch("glusterfs.gfapi.api.glfs_chmod", mock_glfs_chmod): + self.assertRaises(OSError, self.vol.chmod, "file.txt", 0600) + def test_chown_success(self): mock_glfs_chown = Mock() mock_glfs_chown.return_value = 0 |