def test_remove_user(self): """ L{UserManagement.remove_user} should use C{deluser} to remove users. """ data = [("jdoe", "x", 1000, 1000, "JD,,,,", "/home/jdoe", "/bin/zsh")] popen = MockPopen("Removing user `jdoe'...\r\ndone.") provider = FakeUserProvider(users=data, shadow_file=self.shadow_file, popen=popen) management = UserManagement(provider=provider) management.remove_user("jdoe") self.assertEqual(popen.popen_inputs, [["deluser", "jdoe"]])
def test_remove_user_and_home(self): """ L{UserManagement.remove_user} should use C{deluser} to remove the contents of a user's home directory. """ data = [("jdoe", "x", 1000, 1000, "JD,,,,", "/home/jdoe", "/bin/zsh")] popen = MockPopen("Removing user `jdoe`...\r\ndone.", [0]) provider = FakeUserProvider(users=data, shadow_file=self.shadow_file, popen=popen) management = UserManagement(provider=provider) management.remove_user("jdoe", delete_home=True) self.assertEqual(popen.popen_inputs, [["deluser", "jdoe", "--remove-home"]])