def create_random_user(): person = Person('en') name = person.full_name() username = "******".format(name.split(' ')[0], name.split(' ')[1]) password = person.password() return username, name, password
def createPlayers(team): person = Person("en") adress = Address("en") players = [] MAX_N = len(team) arrOfIds = [i + 1 for i in range(MAX_N)] for i in range(MAX_N): positions = [1, 2, 3, 4, 5] numbers = [k for k in range(1, 99, 1)] curTeamID = choice(arrOfIds) arrOfIds.remove(curTeamID) for _ in range(len(positions)): curID = str(len(players) + 1) teamID = str(curTeamID) name = person.full_name() position = choice(positions) height = str(randint(150, 220)) weight = str(person.weight()) number = str(choice(numbers)) age = str(person.age()) country = adress.country(allow_random=True) positions.remove(position) numbers.remove(int(number)) players.append([curID, teamID, name, position, height, weight, number, age, country]) f = open("Players.csv", "w", encoding='utf-8') for player in players: line = str(player[0]) + ',' + str(player[1]) + ',' + str(player[2]) + ',' +\ str(player[3]) + ',' + str(player[4]) + ',' + str(player[5]) + ',' +\ str(player[6]) + ',' + str(player[7]) + ',' + str(player[8]) + '\n' f.write(line) f.close()
def seed(): # Data m_datetime = Datetime() person = Person() dates_range = dict(start=(datetime.utcnow() - timedelta(days=366)).year, end=datetime.utcnow().year) _role = models.Role.query.filter_by(name="Shopper").first() accounts = models.Account.query.filter_by(role=_role).all() for account in accounts: # only make orders for accounts with at least one campaign if not account.campaign: continue # Generate and save orders for _ in range(randint(0, 4)): order = models.Order( account=account, campaign=account.campaign, created_at=m_datetime.datetime(start=dates_range["start"], end=dates_range["end"]), checkout_fields={ "First Name": person.name(), "Last Name": person.last_name() }, ) db.session.add(order) db.session.commit()
class ConcreteBuilder(Builder): def __init__(self) -> None: self.firstname = "Alex" self.surname = "First" self.email = "*****@*****.**" self.phone = "+3809900001" self.password = "******" self.reset() def reset(self) -> None: self._person = Person() @property def person(self) -> Person: person = self._person self.reset() return person def person_name(self) -> None: self._person.add(self.firstname) def person_surname(self) -> None: self._person.add(self.surname) def person_email(self) -> None: self._person.add(self.email) def person_phone(self) -> None: self._person.add(self.phone) def person_password(self) -> None: self._person.add(self.password)
def generatorGender(): person = Person('ru') gend = person.gender() if gend == 'Муж.': return 'M' else: return 'F'
def generate_personal_data(num_records): person = Person('en') payment = Payment() dtype = np.dtype([ ('id', np.unicode_, 16), ('full_name', np.unicode_, 32), ('credit_card_number', np.unicode_, 19), ('credit_card_expiration_date', np.unicode_, 7), ('gender', np.unicode_, 1), ]) np.random.seed() rng = np.random.randint(0, 2, num_records) records_npy = np.empty(num_records, dtype=dtype) for idx in range(num_records): gender = Gender.MALE if rng[idx] == 0 else Gender.FEMALE records_npy['id'][idx] = str(idx).zfill(16) records_npy['full_name'][idx] = person.full_name(gender=gender) records_npy['credit_card_number'][idx] = payment.credit_card_number( card_type=CardType.VISA) records_npy['credit_card_expiration_date'][ idx] = payment.credit_card_expiration_date(maximum=21) records_npy['gender'][idx] = 'M' if rng[idx] == 0 else 'F' return records_npy
def generate_card_info(n=2): res = [] en_text = Text('en') en_person = Person('en') en_business = Business('en') color_choice = Choice() for i in range(n): card = { 'title': en_text.title(), 'author': en_person.full_name(), 'expansion': en_text.word(), 'type': en_text.word(), 'colors': color_choice(items=['white', 'black', 'red', 'green', 'blue'], unique=True, length=2), 'lore_message': en_text.quote(), 'lore_author': en_person.full_name() } res.append(card) return res
def generate_data(self): np.random.seed(seed=self.seed) gender = np.random.randint(2, size=self.num) loan = np.random.randint(self.loan_min / self.loan_step, self.loan_max / self.loan_step, size=self.num) * self.loan_step person = Person('en') payment = Payment() self.main_array = np.empty(shape=self.num, dtype=self.dtype) for idx in range(self.num): self.main_array['id'][idx] = str(idx).zfill(16) self.main_array['full_name'][idx] = person.full_name( gender=Gender.MALE if gender[idx] else Gender.FEMALE) self.main_array['credit_card_number'][ idx] = payment.credit_card_number(card_type=CardType.VISA) self.main_array['credit_card_expiration_date'][ idx] = payment.credit_card_expiration_date(maximum=22) self.main_array['gender'][idx] = 'M' if gender[idx] else 'F' self.main_array['loan'][idx] = loan[idx] same_entries_indices = np.random.choice(np.arange(self.num), self.number_same_name_entries, replace=False) self.main_array['full_name'][same_entries_indices] = self.main_array[ 'full_name'][same_entries_indices[0]] self.main_array['gender'][same_entries_indices] = self.main_array[ 'gender'][same_entries_indices[0]] # makes more sense
def update_db_with_new_entries(count, database): # add 6 * count of lon and lat to the database input_list = [] a = Address() basic_lon, basic_lat = a.coordinates().values() for i in range(count): person = Person('uk') lon1 = basic_lon + 40 * cos(i) lat1 = basic_lat + 40 * sin(i) input_list.append( database( username=person.full_name(), division_order=1, lon1=lon1, lat1=lat1, lon2=lon1 + 1, lat2=lat1 + 2, lon3=lon1 + 3, lat3=lat1 + 2, lon4=lon1 + 4, lat4=lat1 + 0, lon5=lon1 + 3, lat5=lat1 - 2, lon6=lon1 + 1, lat6=lat1 - 2, )) db.session.add_all(input_list) db.session.commit()
def register_new_user(self): person = Person('en') email = person.email() password = person.password(10) self.fill_the_field(*LoginPageLocators.REGISTER_EMAIL, email) self.fill_the_field(*LoginPageLocators.REGISTER_PASSWORD, password) self.fill_the_field(*LoginPageLocators.REGISTER_CONFIRM_PASSWORD, password) self.browser.find_element(*LoginPageLocators.REGISTER_BUTTON).click()