diff options
| author | Thiago da Silva <thiago@redhat.com> | 2015-02-19 17:00:11 -0500 | 
|---|---|---|
| committer | Thiago da Silva <thiago@redhat.com> | 2015-02-19 17:00:11 -0500 | 
| commit | fc318e921b073cdbe9fbe62b8c893634b057f0e8 (patch) | |
| tree | 62623b3d198d2393089846b0e3c0daed42cbe94a /test/unit | |
| parent | ec407b4d61b15506e6ae5b3f28d3983af4f28457 (diff) | |
adding chmod and fchmod
Change-Id: Iba5f4e72a257adeb8ec78b267dfdef26a1ec66f1
Signed-off-by: Thiago da Silva <thiago@redhat.com>
Diffstat (limited to 'test/unit')
| -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  | 
