def insert_random_seller(self, repeat=qsellers): ''' Inserir registros com valores randomicos ''' seller_list = [] for _ in range(repeat): d = gen_timestamp(2014, 2015) + '+00' fname = names.get_first_name() lname = names.get_last_name() email = fname[0].lower() + '.' + lname.lower() + '@example.com' birthday = gen_timestamp() + '+00' active = rstr.rstr('01', 1) internal = rstr.rstr('01', 1) commissioned = rstr.rstr('01', 1) commission = 0.01 seller_list.append( (gen_cpf(), fname, lname, email, gen_phone(), birthday, active, internal, commissioned, commission, d, d)) try: self.db.cursor.executemany(""" INSERT INTO vendas_seller (cpf, firstname, lastname, email, phone, birthday, active, internal, commissioned, commission, created, modified) VALUES (?,?,?,?,?,?,?,?,?,?,?,?) """, seller_list) self.db.commit_db() print("Inserindo %s registros na tabela vendas_seller." % repeat) print("Registros criados com sucesso.") except sqlite3.IntegrityError: print("Aviso: O email deve ser único.") return False
def insert_random_customer(self, repeat=qcustomers): ''' Inserir registros com valores randomicos ''' customer_list = [] for _ in range(repeat): # d = datetime.datetime.now().isoformat(" ") d = gen_timestamp(2014, 2015) + '+00' fname = names.get_first_name() lname = names.get_last_name() email = fname[0].lower() + '.' + lname.lower() + '@example.com' birthday = gen_timestamp() + '+00' customer_list.append( (gen_cpf(), fname, lname, email, gen_phone(), birthday, d, d)) try: self.db.cursor.executemany(""" INSERT INTO vendas_customer (cpf, firstname, lastname, email, phone, birthday, created, modified) VALUES (?,?,?,?,?,?,?,?) """, customer_list) self.db.commit_db() print("Inserindo %s registros na tabela vendas_customer." % repeat) print("Registros criados com sucesso.") except sqlite3.IntegrityError: print("Aviso: O email deve ser único.") return False
last_name = names.get_last_name() name = '{} {}'.format(first_name, last_name) email = '{}.{}@example.com'.format(first_name[0].lower(), last_name.lower()) page = webdriver.Chrome(executable_path='/home/rg3915/Downloads/chromedriver') page.get('http://localhost:8000/inscricao/') search = page.find_element_by_id('id_name') search.send_keys(name) time.sleep(1) search = page.find_element_by_id('id_cpf') search.send_keys(gen_doc()) time.sleep(1) search = page.find_element_by_id('id_email') search.send_keys(email) time.sleep(1) search = page.find_element_by_id('id_phone') search.send_keys(gen_phone()) time.sleep(2) button = page.find_element_by_id('id_submit') button.click() # page.quit()
first_name = names.get_first_name() last_name = names.get_last_name() name = '{} {}'.format(first_name, last_name) email = '{}.{}@example.com'.format(first_name[0].lower(), last_name.lower()) page = webdriver.Firefox() page.maximize_window() time.sleep(0.5) # page = webdriver.Chrome(executable_path='/home/rg3915/Downloads/chromedriver') page.get('http://localhost:8000/inscricao/') time.sleep(0.5) fields = [['id_name', name], ['id_cpf', gen_cpf()], ['id_email', email], ['id_phone', gen_phone()]] for field in fields: search = page.find_element_by_id(field[0]) search.send_keys(field[1]) # time.sleep(0.5) button = page.find_element_by_id('id_submit') button.click() page.quit()
address_list = [] ''' Lendo os dados de address.csv ''' with open('fix/address.csv', 'r') as f: r = csv.DictReader(f) for dct in r: address_list.append(dct) f.close() INDEX = randint(0, 9) fields = [ ['id_first_name', first_name], ['id_last_name', last_name], ['id_email', email], ['id_phone', gen_phone()], ['id_address', address_list[INDEX]['address']], ['id_complement', address_list[INDEX]['complement']], ['id_district', address_list[INDEX]['district']], ['id_city', address_list[INDEX]['city']], ['id_uf', address_list[INDEX]['city']], ['id_cep', address_list[INDEX]['cep']], ['id_person_height', gen_height()], ['id_bust', gen_number(34, 42)], ['id_hip', gen_number(34, 42)], ['id_waist', gen_number(34, 44)], ['id_heel', gen_number(34, 44)], ['id_person_size', gen_number(34, 44)], ] for field in fields: