summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorThiago da Silva <thiago@redhat.com>2015-02-19 17:00:11 -0500
committerThiago da Silva <thiago@redhat.com>2015-02-19 17:00:11 -0500
commitfc318e921b073cdbe9fbe62b8c893634b057f0e8 (patch)
tree62623b3d198d2393089846b0e3c0daed42cbe94a /test
parentec407b4d61b15506e6ae5b3f28d3983af4f28457 (diff)
adding chmod and fchmod
Change-Id: Iba5f4e72a257adeb8ec78b267dfdef26a1ec66f1 Signed-off-by: Thiago da Silva <thiago@redhat.com>
Diffstat (limited to 'test')
-rw-r--r--test/functional/libgfapi-python-tests.py10
-rw-r--r--test/unit/gluster/test_gfapi.py30
2 files changed, 40 insertions, 0 deletions
diff --git a/test/functional/libgfapi-python-tests.py b/test/functional/libgfapi-python-tests.py
index 8bcbf45..4dbdf2d 100644
--- a/test/functional/libgfapi-python-tests.py
+++ b/test/functional/libgfapi-python-tests.py
@@ -163,6 +163,16 @@ class FileOpsTest(unittest.TestCase):
except OSError as e:
self.fail(e.message)
+ def test_chmod(self):
+ stat = self.vol.stat(self.path)
+ orig_mode = oct(stat.st_mode & 0777)
+ self.assertEqual(orig_mode, '0644L')
+ ret = self.vol.chmod(self.path, 0600)
+ self.assertEqual(ret, 0)
+ stat = self.vol.stat(self.path)
+ new_mode = oct(stat.st_mode & 0777)
+ self.assertEqual(new_mode, '0600L')
+
def test_exists(self):
e = self.vol.exists(self.path)
self.assertTrue(e)
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