class UserTest(unittest.TestCase): def runTest(self): unittest.main() def setUp(self): # Generate random 16 byte username u = uuid4() m = md5(u.bytes) self.username = m.hexdigest()[:16] # Use full username as temporary password self.password = m.hexdigest() self.user = User() def test_add_user(self): home = '/home/' + self.username assert self.user.adduser( self.username, self.password, home ) def test_delete_user(self): assert self.user.deluser(self.username)
metavar = 'sudo,staff', default = '', type = 'string', help = 'Comma-separated list of additional groups to delete' ) parser.add_option( '-v', '--verbose', action = 'store_true', dest = 'verbose', help = 'Verbose output' ) (opts, args) = parser.parse_args() try: username = args[0] except: parser.print_usage() exit(1) try: user.deluser(username, opts.groups.split(',')) except Exception as e: print('Problem deleting %s: %s' % (username, str(e)), file=stderr) exit(1) if opts.verbose: print('Finished deleting %s' % username) exit(0)