Exemplo 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')
Exemplo 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')
Exemplo 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')
Exemplo 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')
Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo 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)