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