def handle_get_user_data(self): token = self.get_argument('access_token') fields = [ field for field in self.get_argument('fields', '').split(',') if field ] generator = NameGenerator(lowercase=True, separator=" ") name = generator.generate() user_id = b64encode(str(uuid4())) username = name.lower().replace(' ', '.') birthday = datetime(day=25, month=4, year=random.randint(1970, 2000)) email = "*****@*****.**" % username gender = random.choice(['F', 'M']) names = name.split() first_name = names[0] middle_name = ' '.join(names[1:-1]) last_name = names[-1] relationship = random.choice(['Single', 'Married', 'Complicated']) verified = True userdata = { "id": user_id, "access_token": token, "birthday": birthday.strftime("%m/%d/%Y"), "email": email, "first_name": first_name, "gender": gender, "is_verified": verified, "last_name": last_name, "middle_name": middle_name, "relationship_status": relationship } if fields: data = {'access_token': token} for field in fields: data[field] = userdata[field] userdata = data self.write(dumps(userdata)) self.finish()
def handle_get_user_data(self): token = self.get_argument('access_token') fields = [field for field in self.get_argument('fields', '').split(',') if field] generator = NameGenerator(lowercase=True, separator=" ") name = generator.generate() user_id = b64encode(str(uuid4())) username = name.lower().replace(' ', '.') birthday = datetime(day=25, month=4, year=random.randint(1970, 2000)) email = "*****@*****.**" % username gender = random.choice(['F', 'M']) names = name.split() first_name = names[0] middle_name = ' '.join(names[1:-1]) last_name = names[-1] relationship = random.choice(['Single', 'Married', 'Complicated']) verified = True userdata = { "id": user_id, "access_token": token, "birthday": birthday.strftime("%m/%d/%Y"), "email": email, "first_name": first_name, "gender": gender, "is_verified": verified, "last_name": last_name, "middle_name": middle_name, "relationship_status": relationship } if fields: data = { 'access_token': token } for field in fields: data[field] = userdata[field] userdata = data self.write(dumps(userdata)) self.finish()
def test_can_generate_names_without_species(self): generator = NameGenerator(use_species=False, seed="test-5") expect(generator.generate()).to_equal("Corellia-Rush-Clovis")
def test_can_generate_names_without_characters_and_species(self): generator = NameGenerator(use_characters=False, use_species=False, seed="test-4") expect(generator.generate()).to_equal("Taanab")
def test_can_generate_lowercase_name(self): generator = NameGenerator(lowercase=True, seed="test-3") expect(generator.generate()).to_equal("centax-1-bouncer-thire")
def test_can_generate_names_without_characters(self): generator = NameGenerator(use_characters=False, seed="test-2") expect(generator.generate()).to_equal("Utapau-Yaka")
def test_can_generate_names(self): generator = NameGenerator(seed="test-1") expect(generator.generate()).to_equal("Rori-Latter-Ponda-Baba")