def handle(self, *args, **options): # raise NotImplementedError() Snippet.objects.all().delete() users = [] person = Person() for _ in range(40): User.objects.create(password=person.password(), username=person.username(), first_name=person.name(), last_name=person.last_name(), email=person.email()) text = Text() users = User.objects.all() for _ in range(30): language = choice(['python', 'javascript', 'ruby', 'java']) if language == "java": content = open(BASE_DIR + "/core/fakecode/file.java").read() elif language == "python": content = open(BASE_DIR + "/core/fakecode/python.py").read() elif language == "javascript": content = open(BASE_DIR + "/core/fakecode/javascript.js").read() else: content = open(BASE_DIR + "/core/fakecode/ruby.rb").read() title = text.sentence() if not Snippet.objects.filter(title=title).exists(): Snippet.objects.create(author=choice(users), title=title, language=language, content=content)
def registration_positive_test(self, device: Device) -> None: generator = Person() assert "success" in UserRegistration( Identity(generator.name(), generator.last_name(), generator.telephone()), Credentials(generator.email(), generator.password(), "0"), ).registration_response(device)
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 insert_in_batches(col, total, batch_size): many_people = [] inserted_count = 0 start_time = datetime.utcnow() previous_time = start_time p = Person("en", seed=0xBEE) for i in range(total): proxy_person = { "name": p.first_name(), "surname": p.surname(), "email": p.email(), "password": p.password() } many_people.append(proxy_person) if (len(many_people) % batch_size) == 0: col.insert_many(many_people) inserted_count = inserted_count + len(many_people) time_now = datetime.utcnow() elapsed_time = time_now - previous_time previous_time = time_now print(f"Inserted {len(many_people)} people in {elapsed_time}") many_people.clear() if len(many_people) > 0: col.insert_many(many_people) inserted_count = inserted_count + len(many_people) end_time = datetime.utcnow() duration = end_time - start_time print(f"Inserting {inserted_count} records took {duration}")
def test_sign_up_user(browser): person = Person() TEST_DATA = { 'first_name': person.first_name(), 'last_name': person.last_name(), 'email': person.email(), 'telephone': person.telephone(), 'password': person.password(8) } sign_up_page = SignUpPage(browser) sign_up_page.open() sign_up_page.fill_user_data(first_name=TEST_DATA['first_name'], last_name=TEST_DATA['last_name'], email=TEST_DATA['email'], telephone=TEST_DATA['telephone'], password=TEST_DATA['password']) TopMenu(browser).logout() sign_in_page = SignInPage(browser) sign_in_page.confirm_logout() sign_in_page.open() sign_in_page.login(TEST_DATA['email'], TEST_DATA['password']) assert sign_in_page.get_available_actions_header() == 'My Account'
def get_new_user() -> User: person = Person() username = person.username() email = person.email(domains=["gmail.com", "yahoo.com"]) password = person.password(length=25) user = User(username=username, email=email, password=password) user, error = user.save() return user
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()
def setup(self, driver): link = 'http://selenium1py.pythonanywhere.com/en-gb/catalogue/coders-at-work_207/' page = LoginPage(driver, link) page.open() person = Person('en') page.go_to_login_page() page.register_new_user(person.email(domains=None, unique=False), person.password(length=10, hashed=False)) page.should_be_authorized_user()
def setup(self, browser): link = 'http://selenium1py.pythonanywhere.com/en-gb/accounts/login/' page = LoginPage(browser, link) page.open() user = Person() email = user.email() password = user.password(length=9) page.register_new_user(email, password) page.should_be_authorized_user()
def rediscluster_testset(n): for a in range(n): person = Person('zh') name = person.email() age = person.password() # t=time.asctime(time.localtime(time.time())) rc.set(name, age) print(rc.get(name)) time.sleep(1)
def test_setup(self, browser): person = Person("en") login_link = "http://selenium1py.pythonanywhere.com/en-gb/accounts/login/" email = person.email() password = person.password(length=9) page = LoginPage(browser, login_link) page.open() page.register_new_user(email, password) page.should_be_authorized_user()
def setup(self, browser): link = 'http://selenium1py.pythonanywhere.com/en-gb/' page = MainPage(browser, link) page.open() page.go_to_login_page() login_page = LoginPage(browser, link) person = Person() login_page.register_new_user(person.email(), person.password(length=10)) login_page.should_be_authorized_user()
def test(self, grid: str, device: Device) -> None: chrome: Remote = Chrome(grid) registration = RegisterAccountPage(chrome) registration.load(device) person = Person() registration.fill_personal_details(person.name(), person.last_name(), person.email(), person.telephone()) registration.fill_password(person.password()) registration.press_continue() assert RegistrationSuccessPage(chrome).available()
def persin_test(): person = Person("en") print("u") user_info = dict(username=person.username(), email=person.email(), password=person.password(), real_name=person.full_name(), gender='men', birthday=("1", "3", "1990")) print(user_info)
def generate_users(count=1024, locale="en"): logging.info(f"Generating {count} users.") person = Person(locale) for i in range(count): user = UserModel() user.first_name = person.name() user.last_name = person.surname() user.email = person.email() user.password = person.password() user.phone = person.telephone(mask="###.###.####") user.save()
def test_affiliate_reg(self, device: Device) -> None: urllib3.disable_warnings() person = Person() (assert_if_request_contains_success_response_url( Post( f"https://{device.connections.main.ip}/index.php?route=affiliate/register", { "firstname": person.name(), "lastname": person.last_name(), "email": person.email(), "telephone": person.telephone(), "company": person.full_name(), "website": f"www.{person.username()}.net", "tax": "123456", "payment": "paypal", "paypal": person.email(), "password": person.password(), "confirm": person.password(), "agree": 1, }, )))
def test(self, grid: str, device: Device) -> None: chrome: Remote = Chrome(grid) registration = RegisterAffiliatePage(chrome) person = Person() registration.load(device) registration.fill_personal_details(person.name(), person.last_name(), person.email(), person.telephone()) registration.press_pay_method() registration.fill_information(person.full_name(), f"www.{person.username()}.com", "2332153467", person.email()) registration.fill_password(person.password()) registration.press_continue() assert RegAffiliateSuccessPage(chrome).available()
def setup(self, browser): login = Person() # генерируем логин и пароль с помощью методов класса Person библиотеки mimesis email = login.email(domains=['@gmail.com']) password = login.password(length=9, hashed=False) link = "http://selenium1py.pythonanywhere.com" page = MainPage(browser, link) page.open() page.go_to_login_page() login_page = LoginPage(browser, browser.current_url, email=email, password=password) login_page.register_new_user() login_page.should_be_authorized_user()
def insert_one_at_a_time(col, total): start_time = datetime.utcnow() p = Person("en", seed=0xBEE) for i in range(total): # 0..total-1 proxy_person = { "name": p.first_name(), "surname": p.surname(), "email": p.email(), "password": p.password() } col.insert_one(proxy_person) if ((i + 1) % 10) == 0: print(f"Inserted {i+1} docs") end_time = datetime.utcnow() duration = end_time - start_time print(f"Inserting {i + 1} records took {duration}")
def generate_random_data(): p = Person() a = Address() return { "name": p.full_name(), "email": p.email(), "nationality": p.nationality(), "occupation": p.occupation(), "password": p.password(), "phone": p.telephone(), "address": a.address(), "city": a.city(), "street_no": a.street_number(), "created": Datetime().date().isoformat(), }
def handle(self, *args, **options): Chilipili.objects.all().delete() Like.objects.all().delete() users = [] person = Person() for _ in range(10): User.objects.create(password=person.password(), username=person.username( ), first_name=person.name(), last_name=person.last_name(), email=person.email()) # date = Datetime() text = Text() users = User.objects.all() for _ in range(20): Chilipili.objects.create(author_user=choice( users), text=text.sentence()) chilipilis = Chilipili.objects.all() for _ in range(100): Like.objects.create(like_user=choice( users), chilipili=choice(chilipilis))
from oxwall_site_model import OxwallSite from value_models.status import Status import pytest from data.status_data import status_data from mimesis import Person person = Person("en") user_info = dict(username=person.last_name(), email=person.email(),password=person.password(), real_name=person.full_name(), gender='men', birthday = ("1","3","1990")) print(user_info) #user_info = dict(username="******", email="*****@*****.**", password="******", # real_name="Irena Solo", gender="female", birthday = ("1","3","1990")) #@pytest.mark.skip("doesnt work") def test_join_user(driver,oxwall_app): oxwall_app.main_page.sign_in_click() oxwall_app.sign_in_page.click_to_join() oxwall_app.wait_until_new_status_appeared() oxwall_app.join_page.fill_in_join_form(user_info) actual_text = oxwall_app.dash_page.text_status_new_user print (actual_text) print( user_info["real_name"]+" joined our site!") assert user_info["real_name"]+" joined our site!" == actual_text
class TestUserModel(TestCase): def setUp(self): self.db = db self.db.create_all() self.person = Person() def tearDown(self): self.db.session.remove() self.db.drop_all() def test_user_table(self): self.assertTrue(self.db.engine.has_table(User.__tablename__)) def test_user_mode(self): username = self.person.username() email = self.person.email(domains=["gmail.com"]) password = self.person.password(length=25) user = User(username=username, email=email, password=password) self.assertIsNotNone(user) self.user = user def test_user_save(self): username = self.person.username() email = self.person.email(domains=["gmail.com"]) password = self.person.password(length=25) user = User(username=username, email=email, password=password) user, error = user.save() self.assertFalse(error) self.assertIsInstance(user, User) self.assertNotIsInstance(user, str) self.assertEqual(user.email, email) self.assertEqual(user.email, email) self.assertEqual(user.username, username) self.assertIsInstance(user.joined_at, datetime.datetime) def test_user_repr(self): username = self.person.username() email = self.person.email(domains=["gmail.com"]) password = self.person.password(length=25) user = User(username=username, email=email, password=password) user, error = user.save() self.assertFalse(error) user_string = str(user) self.assertIsNotNone(user_string) def test_user_check_password(self): username = self.person.username() email = self.person.email(domains=["gmail.com"]) password = self.person.password(length=25) user = User(username=username, email=email, password=password) user.save() self.assertTrue(user.check_password(password)) self.assertFalse(user.check_password("wrong password")) def test_user_json_property(self): username = self.person.username() email = self.person.email(domains=["gmail.com"]) password = self.person.password(length=25) user = User(username=username, email=email, password=password) user.save() user_json: Dict[str, Any] = user.json self.assertEqual(user_json.get("uid"), user.uid) self.assertEqual(user_json.get("username"), user.username) self.assertEqual(user_json.get("email"), user.email) def test_user_duplicate_error(self): username = self.person.username() email = self.person.email(domains=["gmail.com"]) password = self.person.password(length=25) user = User(username=username, email=email, password=password) user.save() user2 = User(username=username, email=email, password=password) user2, error = user2.save() self.assertTrue(error) self.assertTrue("duplicate key value violates unique constraint" in user2) def test_add_user_in_bulk(self): users = list() length = 5 for _ in range(length): username = self.person.username() email = self.person.email(domains=["gmail.com", "aol.com"]) password = self.person.password(length=50) users.append(User(username, email, password)) self.db.session.add_all(users) self.assertTrue(User.query.count() >= length) def test_user_level(self): username = self.person.username() email = self.person.email(domains=["gmail.com"]) password = self.person.password(length=25) user_level = UserLevelEnum.ADMIN user = User(username=username, email=email, password=password, _user_level=user_level) user.save() self.assertEqual(user._user_level, user_level) def test_user_address(self): username = self.person.username() email = self.person.email(domains=["gmail.com"]) password = self.person.password(length=25) user_level = UserLevelEnum.USER user = User(username=username, email=email, password=password, _user_level=user_level) user.save() self.assertDictEqual(user.address, {}) address = { "area": "Mohakhali", "city": "Dhaka", "thana": { "name": "Banani", "zip": 1213 } } user, err = user.update(address=address) self.assertFalse(err) self.assertDictEqual(user.address, address) self.assertEqual(user.address.get("city"), address.get("city")) def test_user_phone(self): username = self.person.username() email = self.person.email(domains=["gmail.com"]) password = self.person.password(length=25) user_level = UserLevelEnum.SUPER_ADMIN user = User(username=username, email=email, password=password, _user_level=user_level) user.save() self.assertListEqual(user.phones, []) phones = ["01711111110", "01600000001"] user, err = user.update(phones=phones) self.assertFalse(err) self.assertListEqual(user.phones, phones) self.assertEqual(len(user.phones), len(phones)) def test_user_update_in_bulk(self): users = list() length = 3 for _ in range(length): username = self.person.username() email = self.person.email(domains=["gmail.com", "aol.com"]) password = self.person.password(length=50) users.append(User(username, email, password)) self.db.session.add_all(users) User.update_all(users, address={"city": "Dhaka"}) self.assertTrue(any(user.address != {} for user in users)) for user in users: self.assertEqual(user.address.get("city"), "Dhaka") def test_user_delete(self): username = self.person.username() email = self.person.email(domains=["gmail.com"]) password = self.person.password(length=25) user_level = UserLevelEnum.SUPER_ADMIN user = User(username=username, email=email, password=password, _user_level=user_level) user.save() find_user: User = User.query.filter( User.username == username ).first() self.assertIsNotNone(find_user) find_user.delete() find_user: User = User.query.filter( User.username == username ).first() self.assertIsNone(find_user) def test_user_relationship_laptops(self): username = self.person.username() email = self.person.email(domains=["gmail.com"]) password = self.person.password(length=25) user_level = UserLevelEnum.MODERATOR user = User(username=username, email=email, password=password, _user_level=user_level) user.save() laptop1 = Laptop(user.uid, serial_number="unique_serial_" + Generator.uuid(), mac_address="unique_mac_" + Generator.uuid(), is_stolen=True) laptop2 = Laptop(user.uid, serial_number="unique_serial_" + Generator.uuid(), mac_address="unique_mac_" + Generator.uuid(), remarks="This laptop is imported and genuine operating system installed.") user.laptops.append(laptop1) user.laptops.append(laptop2) db.session.commit() find_user = User.query.get(user.uid) self.assertIsNotNone(find_user) self.assertTrue(find_user.laptops != []) self.assertEqual(len(find_user.laptops), 2) self.assertTrue(laptop1.owner == laptop2.owner) laptops = [laptop1, laptop2] for index, laptop in enumerate(laptops): self.assertEqual(find_user.laptops[index].uid, laptops[index].uid) self.assertEqual(find_user.laptops[index].item_type, ItemTypeEnum.LAPTOP) self.assertEqual(find_user.laptops[index].is_stolen, laptops[index].is_stolen) self.assertEqual(find_user.laptops[index].gd_copy_number, laptops[index].gd_copy_number) self.assertEqual(find_user.laptops[index].remarks, laptops[index].remarks) self.assertEqual(find_user.laptops[index].remarks, laptops[index].remarks) self.assertEqual(find_user.laptops[index].record_time, laptops[index].record_time) self.assertEqual(find_user.laptops[index].last_update, laptops[index].last_update) self.assertEqual(find_user.laptops[index].serial_number, laptops[index].serial_number) self.assertEqual(find_user.laptops[index].mac_address, laptops[index].mac_address) def test_user_relationship_cellphones(self): username = self.person.username() email = self.person.email(domains=["gmail.com"]) password = self.person.password(length=25) user_level = UserLevelEnum.USER user = User(username=username, email=email, password=password, _user_level=user_level) user.save() generic = Generic("en") phone1 = CellPhone(user.uid, imei_1=generic.code.imei()) phone2 = CellPhone(user.uid, imei_1=generic.code.imei(), imei_2=generic.code.imei(), remarks="Dual sim phone.", is_stolen=True, gd_copy_number=f"GD-{Generator.uuid()}") phone3 = CellPhone(user.uid, imei_2=generic.code.imei(), is_stolen=False, remarks="Oneek bhaalo phone!") user.cell_phones.append(phone1) user.cell_phones.append(phone2) user.cell_phones.append(phone3) db.session.commit() find_user = User.query.get(user.uid) self.assertIsNotNone(find_user) self.assertTrue(find_user.cell_phones != []) self.assertEqual(len(find_user.cell_phones), 3) self.assertTrue(phone1.owner == phone2.owner == phone3.owner) phones = [phone1, phone2, phone3] for index, _ in enumerate(phones): self.assertEqual(find_user.cell_phones[index].uid, phones[index].uid) self.assertEqual(find_user.cell_phones[index].item_type, ItemTypeEnum.CELL_PHONE) self.assertEqual(find_user.cell_phones[index].is_stolen, phones[index].is_stolen) self.assertEqual(find_user.cell_phones[index].gd_copy_number, phones[index].gd_copy_number) self.assertEqual(find_user.cell_phones[index].remarks, phones[index].remarks) self.assertEqual(find_user.cell_phones[index].remarks, phones[index].remarks) self.assertEqual(find_user.cell_phones[index].record_time, phones[index].record_time) self.assertEqual(find_user.cell_phones[index].last_update, phones[index].last_update) self.assertEqual(find_user.cell_phones[index].imei_1, phones[index].imei_1) self.assertEqual(find_user.cell_phones[index].imei_2, phones[index].imei_2) def test_user_relationship_vehicles(self): username = self.person.username() email = self.person.email(domains=["gmail.com"]) password = self.person.password(length=25) user_level = UserLevelEnum.ADMIN user = User(username=username, email=email, password=password, _user_level=user_level) user.save() vehicle1 = Vehicle(user.uid, serial_number=f"serial-{Generator.uuid()}") vehicle2 = Vehicle(user.uid, serial_number=f"serial-{Generator.uuid()}", engine_number=f"engine_{Generator.uuid()}") vehicle3 = Vehicle(user.uid, serial_number=f"serial-{Generator.uuid()}", engine_number=f"engine_{Generator.uuid()}", license_number=f"license-{Generator.uuid()}") user.vehicles.append(vehicle1) user.vehicles.append(vehicle2) user.vehicles.append(vehicle3) db.session.commit() find_user = User.query.get(user.uid) self.assertIsNotNone(find_user) self.assertTrue(find_user.vehicles != []) self.assertEqual(len(find_user.vehicles), 3) self.assertTrue(vehicle1.owner == vehicle2.owner == vehicle3.owner) vehicles = [vehicle1, vehicle2, vehicle3] for index, _ in enumerate(vehicles): self.assertEqual(find_user.vehicles[index].uid, vehicles[index].uid) self.assertEqual(find_user.vehicles[index].item_type, ItemTypeEnum.VEHICLE) self.assertEqual(find_user.vehicles[index].is_stolen, vehicles[index].is_stolen) self.assertEqual(find_user.vehicles[index].gd_copy_number, vehicles[index].gd_copy_number) self.assertEqual(find_user.vehicles[index].remarks, vehicles[index].remarks) self.assertEqual(find_user.vehicles[index].remarks, vehicles[index].remarks) self.assertEqual(find_user.vehicles[index].record_time, vehicles[index].record_time) self.assertEqual(find_user.vehicles[index].last_update, vehicles[index].last_update) self.assertEqual(find_user.vehicles[index].serial_number, vehicles[index].serial_number) self.assertEqual(find_user.vehicles[index].engine_number, vehicles[index].engine_number) self.assertEqual(find_user.vehicles[index].license_number, vehicles[index].license_number)
################################################## ### Generate a DataFrame of user information ################################################## # Generate 10,000 rows of the following: # user_id, first_name, last_name, email, password, address, # birth_date, credit_card_num, credit_card_exp, security_answer, # account_balance user_df = pd.DataFrame([[ x, person.name(), person.surname(), person.gender(), person.email(), hashed_passwd(person.password()), address.address(), person.age(), payment.credit_card_number(), payment.credit_card_expiration_date(), text.word(), account_balance(), np.random.randint(1, 11) ] for x in range(10000)]) user_df.columns = [ "user_id", "first_name", "last_name", "gender", "email", "password_hashed", "address", "age", "credit_card_num", "credit_card_exp", "security_answer", "account_balance", "marketing_level" ]
# Connection object c = pymongo.MongoClient( host="mongodb+srv://livedemo:[email protected]/test_db?retryWrites=true&w=majority") # database object database = c["test_db"] # collection/table object collection = database["users"] p = Person("en", seed=0xBEEF) person = {"name": p.first_name(), "surname": p.surname(), "email": p.email(), "password": p.password()} collection.insert_one(person) print("Inserted:") pprint.pprint(person) collection.update_one({"_id": person["_id"]}, {"$set": {"session_id": 20}}) collection.update_one({"_id": person["_id"]}, {"$push": {"phone": {"cell": "+1 123456789"}}}) doc = collection.find_one({"_id": person["_id"]}) print("Updated:") pprint.pprint(doc) collection.update_many({"surname": "Taylor"}, {"$push": {"assets": {"laptop": "MacPro laptop"}}}) laptop_count = collection.count_documents({"surname": "Taylor", "assets.laptop": "MacPro laptop"}) print(f"We have allocated {laptop_count} laptops")
def get_fake_authentication(self, loc): per = Person(loc) nickname = per.username(template=None) email = per.email(domains=None) password = per.password(8) return nickname, email, password
def setup(self): person = Person('en') self.email = person.email() self.password = person.password(9)
def setUpClass(cls): """Generate some fake data.""" cls.app = Flask('test') util.init_app(cls.app) cls.app.config['CLASSIC_DATABASE_URI'] = 'sqlite:///test.db' cls.app.config['CLASSIC_SESSION_HASH'] = 'foohash' cls.app.config['CLASSIC_SESSION_TIMEOUT'] = '36000' with cls.app.app_context(): util.create_all() COUNT = 50 cls.users = [] _users = [] _domain_users = [] for i in range(COUNT): with util.transaction() as session: locale = _get_locale() person = Person(locale) net = Internet(locale) ip_addr = net.ip_v4() email = person.email() approved = 1 if _prob(90) else 0 deleted = 1 if _prob(2) else 0 banned = 1 if random.randint(0, 100) <= 1 else 0 first_name = person.name() last_name = person.surname() suffix_name = person.title() name = (first_name, last_name, suffix_name) joined_date = util.epoch( Datetime(locale).datetime().replace(tzinfo=EASTERN)) db_user = models.DBUser( first_name=first_name, last_name=last_name, suffix_name=suffix_name, share_first_name=1, share_last_name=1, email=email, flag_approved=approved, flag_deleted=deleted, flag_banned=banned, flag_edit_users=0, flag_edit_system=0, flag_email_verified=1, share_email=8, email_bouncing=0, policy_class=2, # Public user. TODO: consider admin. joined_date=joined_date, joined_ip_num=ip_addr, joined_remote_host=ip_addr) session.add(db_user) # Create a username. username_is_valid = 1 if _prob(90) else 0 username = person.username() db_nick = models.DBUserNickname( user=db_user, nickname=username, flag_valid=username_is_valid, flag_primary=1) # Create the user's profile. archive, subject_class = _random_category() db_profile = models.DBProfile( user=db_user, country=locale, affiliation=person.university(), url=net.home_page(), rank=random.randint(1, 5), archive=archive, subject_class=subject_class, original_subject_classes='', flag_group_math=1 if _prob(5) else 0, flag_group_cs=1 if _prob(5) else 0, flag_group_nlin=1 if _prob(5) else 0, flag_group_q_bio=1 if _prob(5) else 0, flag_group_q_fin=1 if _prob(5) else 0, flag_group_stat=1 if _prob(5) else 0) # Set the user's password. password = person.password() db_password = models.DBUserPassword( user=db_user, password_storage=2, password_enc=util.hash_password(password)) # Create some endorsements. archive, subject_class = _random_category() net_points = 0 for _ in range(0, random.randint(1, 4)): etype = random.choice(['auto', 'user', 'admin']) point_value = random.randint(-10, 10) net_points += point_value if len(_users) > 0 and etype == 'auto': endorser_id = random.choice(_users).user_id else: endorser_id = None issued_when = util.epoch( Datetime(locale).datetime().replace( tzinfo=EASTERN)) session.add( models.DBEndorsement(endorsee=db_user, endorser_id=endorser_id, archive=archive, subject_class=subject_class, flag_valid=1, endorsement_type=etype, point_value=point_value, issued_when=issued_when)) session.add(db_password) session.add(db_nick) session.add(db_profile) _users.append(db_user) _domain_users.append( (domain.User(user_id=str(db_user.user_id), username=db_nick.nickname, email=db_user.email, name=domain.UserFullName( forename=db_user.first_name, surname=db_user.last_name, suffix=db_user.suffix_name), verified=bool( db_user.flag_email_verified)), domain.Authorizations( classic=util.compute_capabilities(db_user), ))) session.commit() # We'll use these data to run tests. cls.users.append(( email, username, password, name, (archive, subject_class, net_points), (approved, deleted, banned), ))
twitter_user INT REFERENCES twitteruser ON DELETE CASCADE NOT NULL)""" ) c.execute( """CREATE TABLE IF NOT EXISTS notifications(id SERIAL NOT NULL PRIMARY KEY, tweet REFERENCES tweet_table ON DELETE CASCADE NOT NULL, receiver INT REFERENCES twitteruser ON DELETE CASCADE NOT NULL)""") conn.commit() for new_user in range(500): c.execute( 'INSERT INTO twitteruser(id, username, password, display_name) VALUES(?,?,?,?)', [ new_user + 1, person.username(), person.password(), person.full_name() ], ) for new_tweet in range(1000): c.execute( 'INSERT INTO tweet(id, tweet, twitter_user) VALUES(?,?,(SELECT id FROM twitteruser ORDER BY RANDOM() LIMIT 1001))', [new_tweet + 1, text.text(quantity=1)]) for new_notification in range(200): rand_user = random.sample(range(1, 500), 2) rand_sender = random.choice(rand_user) c.execute( 'INSERT INTO notifications(id, tweet, receiver) VALUES(?,?,(SELECT id FROM twitteruser ORDER BY RANDOM() LIMIT 201) )', [new_notification + 1, rand_sender])
gated_age = np.heaviside(df[age] - min_age, 0.5) - np.heaviside(df[age] - max_age, 0.5) return 0.01*pow(np.abs(df[age] - 30), 2.5) + df[age] + 50*df[marketing_level]*gated_age + 2*df[account_balance] + noise ################################################## ################################################## ### Generate a DataFrame of user information ################################################## # Generate 10,000 rows of the following: # user_id, first_name, last_name, email, password, address, # birth_date, credit_card_num, credit_card_exp, security_answer, # account_balance user_df = pd.DataFrame([[x, person.name(), person.surname(), person.gender(), person.email(), hashed_passwd(person.password()), address.address(), person.age(), payment.credit_card_number(), payment.credit_card_expiration_date(), text.word(), account_balance(), np.random.randint(1, 11)] for x in range(10000)]) user_df.columns = ["user_id", "first_name", "last_name", "gender", "email", "password_hashed", "address", "age", "credit_card_num", "credit_card_exp", "security_answer", "account_balance", "marketing_level"] # Generate sales, based on a noisy linear model user_df['sales'] = generate_sales(user_df) user_df['sales'] = user_df['sales'] - user_df['sales'].min()