def test_users_remove(mocker): """ Given a user dictionary, `users.remove(...)` should utilize `userdel` to delete the user. """ mocker.patch('subprocess.call') users.remove(user_dict) subprocess.call.assert_called_with(['userdel', '-r', 'kehinde'])
def test_users_remove(mocker): """ users.remove should call userdel with the right arguments """ mocker.patch('subprocess.run') users.remove(user_dict['name']) subprocess.run.assert_called_with(remove_command, check=True)
def test_remove(mocker): """ given a user dictionary user.remove should remove a user """ mocker.patch('subprocess.run') users.remove('bruce') subprocess.run.assert_called()
def test_users_remove(mocker): """ Delete the user based on the user dictionary """ mocker.patch('subprocess.call') users.remove(user_dict) subprocess.call.assert_called_with([ 'userdel', '-r', 'kevin', ])
def test_users_remove(mocker): """ Given a user dictionary. 'user.remove(...)' should remove a user from the system using the 'userdel' linux command. """ mocker.patch('subprocess.call') users.remove(user_dict) subprocess.call.assert_called_with([ 'userdel', '-r', 'kevin', ])
def test_users_remove(mocker): """ Given a user dictionary, `users.remove(...)` should utilize `userdel` to remove the user and home directory. """ mocker.patch('subprocess.call') users.remove(user_dict) subprocess.call.assert_called_with([ 'userdel', '-r', 'kevin', ])
def test_users_remove(mocker): """ Given a user dictionary, `users.remove(...)` should utilize `userdel` to delte the user :param mocker: :return: """ mocker.patch('subprocess.call') users.remove(user_dict) subprocess.call.assert_called_with([ 'userdel', '-r', 'kevin', ])
if index == 0: group_str += group else: group_str += ",%s" % group index+=1 # To manually test this you’ll need to (temporarily) run the following from within your project’s directory: sudo pip3.6 install -e . # Then you will be able to run the following to be able to use your module in a REPL without getting permissions # errors for calling out to usermod, userdel, and useradd: sudo python3.6 >>> from hr import users >>> password = '******' >>> user_dict = { ... 'name': 'kevin', ... 'groups': ['wheel'], ... 'password': password ... } >>> users.add(user_dict) Adding user 'kevin' >>> user_dict['groups'] = [] >>> users.update(user_dict) Updating user 'kevin' >>> users.remove(user_dict) Removing user 'kevin' >>>