def create_or_get_user(contest_id): global num_users num_users += 1 def enumerify(x): if 11 <= x <= 13: return 'th' return {1: 'st', 2: 'nd', 3: 'rd'}.get(x % 10, 'th') username = "******" % num_users # Find a user that may already exist (from a previous contest). users = get_users(contest_id) user_create_args = { "username": username, "password": "******", "first_name": "Ms. Test", "last_name": "Wabbit the %d%s" % (num_users, enumerify(num_users)), } if username in users: user_id = users[username]['id'] add_existing_user(contest_id, user_id, **user_create_args) info("Using existing user with id %d." % user_id) else: user_id = add_user(contest_id, **user_create_args) info("Created user with id %d." % user_id) return user_id
def create_or_get_user(self): """Create a new user if it doesn't exists already. return (int): user id. """ self.num_users += 1 def enumerify(x): if 11 <= x <= 13: return 'th' return {1: 'st', 2: 'nd', 3: 'rd'}.get(x % 10, 'th') username = "******" % (self.rand, self.num_users) # Find a user that may already exist (from a previous contest). users = get_users(self.contest_id) user_create_args = { "username": username, "password": "******", "method": "plaintext", "first_name": "Ms. Test", "last_name": "Wabbit the %d%s" % (self.num_users, enumerify(self.num_users)) } if username in users: self.user_id = users[username]['id'] add_existing_user(self.user_id, **user_create_args) logging.info("Using existing user with id %s.", self.user_id) else: self.user_id = add_user(contest_id=str(self.contest_id), **user_create_args) logging.info("Created user with id %s.", self.user_id) return self.user_id
def create_or_get_user(self): """Create a new user if it doesn't exists already. return (int): user id. """ self.num_users += 1 def enumerify(x): if 11 <= x <= 13: return 'th' return {1: 'st', 2: 'nd', 3: 'rd'}.get(x % 10, 'th') username = "******" % (self.rand, self.num_users) # Find a user that may already exist (from a previous contest). users = get_users(self.contest_id) user_create_args = { "username": username, "password": "******", "first_name": "Ms. Test", "last_name": "Wabbit the %d%s" % (self.num_users, enumerify(self.num_users)), "multipart_post": True, } if username in users: self.user_id = users[username]['id'] add_existing_user(self.user_id, **user_create_args) logging.info("Using existing user with id %s.", self.user_id) else: self.user_id = add_user(contest_id=str(self.contest_id), **user_create_args) logging.info("Created user with id %s.", self.user_id) return self.user_id
def create_a_user(contest_id): global num_users num_users += 1 def enumerify(x): if 11 <= x <= 13: return 'th' return {1: 'st', 2: 'nd', 3: 'rd'}.get(x % 10, 'th') info("Creating user.") user_id = add_user(contest_id=contest_id, username="******" % num_users, password="******", first_name="Ms. Test", last_name="Wabbit the %d%s" % (num_users, enumerify(num_users))) return user_id
def create_a_user(contest_id): global num_users num_users += 1 def enumerify(x): if 11 <= x <= 13: return 'th' return {1: 'st', 2: 'nd', 3: 'rd'}.get(x % 10, 'th') info("Creating user.") user_id = add_user( contest_id=contest_id, username="******" % num_users, password="******", first_name="Ms. Test", last_name="Wabbit the %d%s" % (num_users, enumerify(num_users))) return user_id