Esempio n. 1
0
 def test_chown_group(self):
     "Use named user"
     with patch.object(nix.grp, 'getgrnam') as pgrp:
         pgrp.return_value = [None, None, 100]
         with patch.object(nix.os, 'chown') as pchown:
             nix.chown('/hai', group='larry')
             pchown.assert_called_once_with('/hai', -1, 100)
             pgrp.assert_called_once_with('larry')
Esempio n. 2
0
 def test_chown_group(self):
     "Use named user"
     with patch.object(nix.grp, 'getgrnam') as pgrp:
         pgrp.return_value =  [None, None, 100]
         with patch.object(nix.os, 'chown') as pchown:
             nix.chown('/hai', group='larry')
             pchown.assert_called_once_with('/hai', -1, 100)
             pgrp.assert_called_once_with('larry')
Esempio n. 3
0
 def test_chown_user(self):
     "Use named user"
     with patch.object(nix.pwdb, 'getpwnam') as ppwd:
         ppwd.return_value = [None, None, 100]
         with patch.object(nix.os, 'chown') as pchown:
             nix.chown('/hai', user='******')
             pchown.assert_called_once_with('/hai', 100, -1)
             ppwd.assert_called_once_with('larry')
Esempio n. 4
0
 def test_chown_user(self):
     "Use named user"
     with patch.object(nix.pwdb, 'getpwnam') as ppwd:
         ppwd.return_value =  [None, None, 100]
         with patch.object(nix.os, 'chown') as pchown:
             nix.chown('/hai', user='******')
             pchown.assert_called_once_with('/hai', 100, -1)
             ppwd.assert_called_once_with('larry')
Esempio n. 5
0
 def test_chown_badargs(self):
     "Raise if nonsense args"
     starargs = [
         dict(uid=100, user='******'), {},
         dict(gid=-1, group='users'),
         dict(gid=10, uid=20, user='******')
     ]
     for case in starargs:
         with self.assertRaises(ValueError):
             nix.chown('/foo', **case)
Esempio n. 6
0
 def test_chown_badargs(self):
     "Raise if nonsense args"
     starargs = [
         dict(uid=100, user='******'),
         {},
         dict(gid= -1, group='users'),
         dict(gid=10, uid=20, user='******')
         ]
     for case in starargs:
         with self.assertRaises(ValueError):
             nix.chown('/foo', **case)
Esempio n. 7
0
 def test_chown_str(self):
     "Can we chown a path?"
     with patch.object(nix.os, 'chown') as pchown:
         nix.chown('/hai', uid=100)
         pchown.assert_called_once_with('/hai', 100, -1)
Esempio n. 8
0
 def test_chown_uid(self):
     "Use user id"
     with patch.object(nix.os, 'chown') as pchown:
         nix.chown('/hai', uid=100)
         pchown.assert_called_once_with('/hai', 100, -1)
Esempio n. 9
0
 def test_chown_gid(self):
     "Use group id"
     with patch.object(nix.os, 'chown') as pchown:
         nix.chown('/hai', gid=100)
         pchown.assert_called_once_with('/hai', -1, 100)
Esempio n. 10
0
 def test_chown_str(self):
     "Can we chown a path?"
     with patch.object(nix.os, 'chown') as pchown:
         nix.chown('/hai', uid = 100)
         pchown.assert_called_once_with('/hai', 100, -1)
Esempio n. 11
0
 def test_chown_uid(self):
     "Use user id"
     with patch.object(nix.os, 'chown') as pchown:
         nix.chown('/hai', uid=100)
         pchown.assert_called_once_with('/hai', 100, -1)
Esempio n. 12
0
 def test_chown_gid(self):
     "Use group id"
     with patch.object(nix.os, 'chown') as pchown:
         nix.chown('/hai', gid=100)
         pchown.assert_called_once_with('/hai', -1, 100)