From fc318e921b073cdbe9fbe62b8c893634b057f0e8 Mon Sep 17 00:00:00 2001 From: Thiago da Silva Date: Thu, 19 Feb 2015 17:00:11 -0500 Subject: adding chmod and fchmod Change-Id: Iba5f4e72a257adeb8ec78b267dfdef26a1ec66f1 Signed-off-by: Thiago da Silva --- test/unit/gluster/test_gfapi.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'test/unit') 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 -- cgit