def test_adduser(self): ''' Tests if specified user gets added in the group. ''' mock = MagicMock(return_value={'retcode': 0}) with patch.dict(groupadd.__grains__, {'kernel': 'Linux'}): with patch.dict(groupadd.__salt__, {'cmd.retcode': mock}): self.assertFalse(groupadd.adduser('test', 'root')) with patch.dict(groupadd.__grains__, {'kernel': ''}): with patch.dict(groupadd.__salt__, {'cmd.retcode': mock}): self.assertFalse(groupadd.adduser('test', 'root'))
def test_adduser(self): """ Tests if specified user gets added in the group. """ mock = MagicMock(return_value={"retcode": 0}) with patch.dict(groupadd.__grains__, {"kernel": "Linux"}): with patch.dict(groupadd.__salt__, {"cmd.retcode": mock}): self.assertFalse(groupadd.adduser("test", "root")) with patch.dict(groupadd.__grains__, {"kernel": ""}): with patch.dict(groupadd.__salt__, {"cmd.retcode": mock}): self.assertFalse(groupadd.adduser("test", "root"))
def test_adduser(self): ''' Tests if specified user gets added in the group. ''' os_version_list = [ { 'grains': { 'kernel': 'Linux', 'os_family': 'RedHat', 'osmajorrelease': '5' }, 'cmd': ('gpasswd', '-a', 'root', 'test') }, { 'grains': { 'kernel': 'Linux', 'os_family': 'Suse', 'osmajorrelease': '11' }, 'cmd': ('usermod', '-A', 'test', 'root') }, { 'grains': { 'kernel': 'Linux' }, 'cmd': ('gpasswd', '--add', 'root', 'test') }, { 'grains': { 'kernel': 'OTHERKERNEL' }, 'cmd': ('usermod', '-G', 'test', 'root') }, ] for os_version in os_version_list: mock = MagicMock(return_value={'retcode': 0}) with patch.dict(groupadd.__grains__, os_version['grains']): with patch.dict(groupadd.__salt__, {'cmd.retcode': mock}): self.assertFalse(groupadd.adduser('test', 'root')) groupadd.__salt__['cmd.retcode'].assert_called_once_with( os_version['cmd'], python_shell=False)
def test_adduser(self): """ Tests if specified user gets added in the group. """ os_version_list = [ { "grains": { "kernel": "Linux", "os_family": "RedHat", "osmajorrelease": "5", }, "cmd": ["gpasswd", "-a", "root", "test"], }, { "grains": { "kernel": "Linux", "os_family": "Suse", "osmajorrelease": "11", }, "cmd": ["usermod", "-A", "test", "root"], }, { "grains": { "kernel": "Linux" }, "cmd": ["gpasswd", "--add", "root", "test"], }, { "grains": { "kernel": "OTHERKERNEL" }, "cmd": ["usermod", "-G", "test", "root"], }, ] for os_version in os_version_list: mock = MagicMock(return_value={"retcode": 0}) with patch.dict(groupadd.__grains__, os_version["grains"]): with patch.dict(groupadd.__salt__, {"cmd.retcode": mock}): self.assertFalse(groupadd.adduser("test", "root")) groupadd.__salt__["cmd.retcode"].assert_called_once_with( os_version["cmd"], python_shell=False)
def test_adduser(self): """ Tests if specified user gets added in the group. """ os_version_list = [ { "grains": {"kernel": "Linux", "os_family": "RedHat", "osmajorrelease": "5"}, "cmd": ("gpasswd", "-a", "root", "test"), }, { "grains": {"kernel": "Linux", "os_family": "Suse", "osmajorrelease": "11"}, "cmd": ("usermod", "-A", "test", "root"), }, {"grains": {"kernel": "Linux"}, "cmd": ("gpasswd", "--add", "root", "test")}, {"grains": {"kernel": "OTHERKERNEL"}, "cmd": ("usermod", "-G", "test", "root")}, ] for os_version in os_version_list: mock = MagicMock(return_value={"retcode": 0}) with patch.dict(groupadd.__grains__, os_version["grains"]): with patch.dict(groupadd.__salt__, {"cmd.retcode": mock}): self.assertFalse(groupadd.adduser("test", "root")) groupadd.__salt__["cmd.retcode"].assert_called_once_with(os_version["cmd"], python_shell=False)