def setUp(self): self.driver = ModelConfig.driver_web browser_name = self.driver.capabilities['browserName'] if browser_name == "chrome": self.driver.maximize_window() # login login(self) # ENVIROMENT SETTING code = """ client = {0} campaign = {1} cur.execute("DELETE FROM clients WHERE email = '%s'" % client[0]['email']) cur.execute("DELETE FROM campaigns WHERE name = '%s'" % campaign[0]['name']) sql_clients = 'INSERT INTO clients (person_contact, cpm, budget, status, email, "created_at", updated_at, ' \ 'password, company_name, rfc, phone, address) ' \ 'VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s, %s) RETURNING id' val_clients = (client[0]['name'], client[0]['cpm'], client[0]['budget'], 1, client[0]['email'],strftime("%Y/%m/%d"), \ strftime("%Y/%m/%d"), client[0]['password'], client[0]['company'], client[0]['rfc'], client[0]['phone'], \ client[0]['address']) cur.execute(sql_clients, val_clients) sql_campaign = 'INSERT INTO campaigns (url, cam_code, name, budget, objetive, industry, category, created_at, ' \ 'updated_at, redirect_url, script_snippet, status, dbm_client_secret, dbm_client_id, ' \ 'client_id) ' \ 'VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)' val_campaign = (campaign[0]['url'], campaign[0]['camcode'], campaign[0]['name'], campaign[0]['budget'], campaign[0]['objetive'], campaign[0]['industry'], campaign[0]['category'], strftime("%Y/%m/%d"), strftime("%Y/%m/%d"), '', '', 1, '', '', cur.fetchone()[0]) cur.execute(sql_campaign, val_campaign)""".format(client, campaign) db_functions(code)
def setUpClass(cls): info = json.loads(dashboard_user) code = """ info = {0} client = "{client}" for d_user in info: cur.execute("SELECT du.user_id FROM dashboard_users AS du JOIN users ON du.user_id = users.id where name = '%s' " "and email = '%s'" % (d_user['name'], d_user['email'])) try: id = cur.fetchone()[0] cur.execute("DELETE FROM dashboard_users WHERE user_id=%s" % id) cur.execute("DELETE FROM admin_historicaluser WHERE history_user_id = %s" % id) cur.execute("DELETE FROM users WHERE id = %s" % id) except Exception as errorException: errorException cur.execute("INSERT INTO users (name, password, status, email, created_at, updated_at, is_active, is_client) VALUES " "('%s', '%s', 1, '%s', current_timestamp, current_timestamp, true, true) RETURNING id;" % (info[0]['name'], info[0]['password'], info[0]['email'])) id = cur.fetchone()[0] cur.execute("SELECT id FROM clients WHERE email = '%s'" % client) id_client = cur.fetchone()[0] cur.execute("INSERT INTO dashboard_users (client_id, user_id) VALUES (%s, %s)" % (id_client, id)) """.format(info, client=client) db_functions(code) cls.driver = ModelConfig.driver_web cls.dashboard_main(cls)
def setUp(self): global campaign delete_file(file_path) self.driver = ModelConfig.driver_web self.driver.maximize_window() code = """ info = {0} cur.execute("DELETE FROM campaigns WHERE name = '%s' AND budget = '%s' AND objetive = '%s'" %(info[0]['name'], info[0]['budget'], info[0]['objetive'])) """.format(info) db_functions(code)
def setUp(self): code = """ info = {0} cur.execute("DELETE FROM users WHERE email = '%s'" % info[0]['email']) cur.execute("DELETE FROM admin_historicaluser WHERE email = '%s'" % info[0]['email']) sql = 'INSERT INTO users (name, password, status, email, created_at, updated_at, is_active, is_client)' \ ' VALUES (%s, %s, %s, %s, current_timestamp, current_timestamp, %s, %s) returning email' val = (info[0]['name'], info[0]['password'], '1', info[0]['email'], 'true', 'false') cur.execute(sql, val) """.format(users) db_functions(code) self.driver = ModelConfig.driver_web self.driver.maximize_window()
def setUp(self): global browser_name, campaign csv_list = read_csv(root_files + 'creatives/creativesSuccess.csv') code = """ csv_list = {0} campaign = {1} for creative in csv_list: cur.execute("DELETE FROM creatives WHERE name = '%s' AND campaign_id = %d;" % (creative["name"],campaign)) """.format(csv_list, campaign) db_functions(code) self.driver = ModelConfig.driver_web browser_name = self.driver.capabilities['browserName'] if browser_name == "chrome": self.driver.maximize_window()
def testuserempty(self): driver = self.driver info = json.loads(dashboard_success) code = """ info = {0} cur.execute("SELECT du.user_id FROM dashboard_users AS du JOIN users ON du.user_id = users.id where name = '%s' " "and email = '%s'" % (info[0]['name'], info[0]['email'])) try: id = cur.fetchone()[0] cur.execute("DELETE FROM users u USING dashboard_users du JOIN users u ON u.id = user_id JOIN "admin_historicaluser hu ON history_user_id=u.id WHERE duser_id = u.id AND u.id = history_user_id AND " "u.id = %s" % id) # cur.execute("DELETE FROM admin_historicaluser WHERE history_user_id = %s" % id) # cur.execute("DELETE FROM users WHERE id = %s" % id) except Exception as errorException: errorException """.format(info) db_functions(code) login(self) driver.find_element_by_xpath('//*[@id="inputSrc"]').click() sleep(1) driver.find_element_by_xpath('//*[@id="search"]').send_keys(client) sleep(1) # view driver.find_element_by_xpath('//*[@id="clienttable"]/tbody/tr[1]/td[5]/a[1]').click() sleep(3) # button_dashboard driver.find_element_by_xpath('//*[@id="btn-add-"]').click() sleep(3) # email driver.find_element_by_xpath('//*[@id="add-dash-user-email"]')\ .send_keys((info[0]["email"])) # name driver.find_element_by_xpath('//*[@id="add-dash-user-name"]')\ .send_keys((info[0]["name"])) sleep(3) # password driver.find_element_by_xpath('//*[@id="add-dash-user-password1"]')\ .send_keys((info[0]["password"])) # confirmation de password driver.find_element_by_xpath('//*[@id="add-dash-user-password2"]')\ .send_keys((info[0]["password"])) # save driver.find_element_by_xpath('//*[@id="modal-add-dashboard-user"]/div/div/div[3]/button').click() sleep(3) # asser self.assertEqual(info[0]["name"], driver.find_element_by_xpath('//*[@id="user-dashboard"]/div/div/div[2]') .text, msg=None) self.assertEqual(info[0]["email"], driver.find_element_by_xpath('//*[@id="user-dashboard"]/div/div/div[1]') .text, msg=None)
def setUpClass(cls): global users cls.driver = ModelConfig.driver_web info = json.loads(users) code = """ info = {0} cur.execute("DELETE FROM users WHERE email = '%s'" % info[0]['email']) cur.execute("DELETE FROM admin_historicaluser WHERE email = '%s'" % info[0]['email']) sql = 'INSERT INTO users (name, password, status, email, created_at, updated_at, is_active, is_client)' \ ' VALUES (%s, %s, %s, %s, current_timestamp, current_timestamp, %s, %s) returning email' val = (info[0]['name'], info[0]['password'], '1', info[0]['email'], 'true', 'false') cur.execute(sql, val) """.format(info) db_functions(code) cls.create_setup(cls)
def setUpClass(cls): global browser_name, creative code = """ campaign = {1} list_creatives = {0} for creative in list_creatives: cur.execute("DELETE FROM creatives WHERE campaign_id = %d AND name = '%s';" % (campaign, creative["name"])) rand = random.randint(0, len(list_creatives)-1) cur.execute("INSERT INTO creatives (name, url, measure, type, status, created_at, updated_at, campaign_id," "creative_code, file_url, redirect_url, script_snippet) VALUES " "('%s', '%s', '%s', '%s', %d, current_timestamp, current_timestamp, %d, '', '', '', '') RETURNING id;" % (list_creatives[rand]["name"], list_creatives[rand]["url"], list_creatives[rand]["measure"], list_creatives[rand]["type"], list_creatives[rand]["status"], campaign)) id = cur.fetchone()[0] cur.execute("UPDATE creatives SET creative_code = '%s-%d', " "redirect_url = 'https://hnz3ccup03.execute-api.us-west-2.amazonaws.com/stage/" "redirect?ca=PRUEBA-2&ct=CESAR-17&adUrl=http://www.arca-stage.vjdbsvf9qh.us-west-2.elasticbeanstalk.com" "/customer/dashboard', script_snippet = '<script id=cer-tracking src=https://d260gejhgij5g1.cloudfront.net/" "js/libs/cer.min.js?ca=PRUEBA-2&ct=CESAR-17></script>' " "WHERE ID = %d RETURNING id;" % (list_creatives[rand]["name"].upper(), id, id)) """.format(list_creatives, campaign) creative = db_functions(code)[0][0] cls.driver = ModelConfig.driver_web browser_name = cls.driver.capabilities['browserName'] if browser_name == "chrome": cls.driver.maximize_window() # noinspection PyTypeChecker,PyCallByClass cls.go_to_creative(cls)
def setUpClass(cls): cls.driver = ModelConfig.driver_web cls.driver.maximize_window() code = """ info = {0} client = "{1}" cur.execute("SELECT id FROM clients WHERE email = '%s'" % client) id_client = cur.fetchone()[0] cur.execute("DELETE FROM campaigns WHERE name = '%s' AND budget = %s AND objetive = %s" % (info[1]['name'], info[1]['budget'], info[1]['objetive'])) sql = 'INSERT INTO campaigns (url, cam_code, name, budget, objetive, industry, category, created_at, updated_at,' \ 'redirect_url, script_snippet, status, dbm_client_secret, dbm_client_id, client_id) ' \ 'VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)' val = (info[0]['url'], info[0]['camcode'], info[0]['name'], info[0]['budget'], info[0]['objetive'], info[0]['industry'], info[0]['category'], strftime("%Y/%m/%d"), strftime("%Y/%m/%d"), '', '', 1, '', '', id_client) """.format(info, client) db_functions(code) cls.campaign_main(cls)
def setUp(self): global users self.driver = ModelConfig.driver_web # Preparation of environment info = json.loads(users) # rand=randint(0, len(info)-1) # to send the JSON logs code = """ info = {0} cur.execute("DELETE FROM users WHERE email = '%s'" % info[0]['email']) cur.execute("DELETE FROM admin_historicaluser WHERE email = '%s'" % info[0]['email']) sql = 'INSERT INTO users (name, password, status, email, created_at, updated_at, is_active, is_client)' \ ' VALUES (%s, %s, %s, %s, current_timestamp, current_timestamp, %s, %s) returning email' val = (info[0]['name'], info[0]['password'], '1', info[0]['email'], 'true', 'false') cur.execute(sql, val) """.format(info) db_functions(code)
def setUp(self): global clients self.driver = ModelConfig.driver_web self.driver.maximize_window() # ENVIROMENT SETTING info = json.loads(clients) code = """ info = {0} for element in info: cur.execute("SELECT id FROM clients WHERE email = '%s'" % element['email']) try: id = cur.fetchone()[0] if id is not None: cur.execute("DELETE FROM campaigns WHERE client_id = '%d';" % id) cur.execute("DELETE FROM clients WHERE id = '%d';" % id) except Exception as errorFetch: errorFetch """.format(info) db_functions(code)
def setUp(self): global browser_name, campaign, creative_name csv_list = read_csv(root_files + 'creatives\creativesValidation .csv') code = """ csv_list = {0} campaign = {1} creative_name = "editado3" cur.execute("DELETE FROM creatives WHERE campaign_id = %d AND name = '%s';" % (campaign, creative_name)) for creative in csv_list: if creative["name"] == creative_name: cur.execute("INSERT INTO creatives (name, url, measure, type, status, created_at, updated_at, campaign_id," "creative_code, file_url, redirect_url, script_snippet) VALUES ('%s', '%s', '%s'," "'%s', %d, current_timestamp, current_timestamp, %d, '', '', '', '') RETURNING id;" % (creative["name"], creative["url"], creative["measure"], creative["type"], campaign)) """.format(csv_list, campaign, creative_name) db_functions(code) self.driver = ModelConfig.driver_web browser_name = self.driver.capabilities['browserName'] if browser_name == "chrome": self.driver.maximize_window()
def setUp(self): self.driver = ModelConfig.driver_web self.driver.maximize_window() # ENVIROMENT SETTING info = json.loads(clients) code = """ info = {0} cur.execute("SELECT id FROM clients WHERE email = '%s'" % info[0]['email']) try: id = cur.fetchone()[0] if id is not None: cur.execute("DELETE FROM campaigns WHERE client_id = '%d';" % id) cur.execute("DELETE FROM clients WHERE id = '%d';" % id) except Exception as errorFetch: errorFetch sql = 'INSERT INTO clients (person_contact, cpm, budget, status, email, "created_at", updated_at, ' \ 'password, company_name, rfc, phone, address) ' \ 'VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s, %s)' val = (info[0]['name'], info[0]['cpm'], info[0]['budget'], 1, info[0]['email'], strftime("%Y/%m/%d"), \ strftime("%Y/%m/%d"), info[0]['password'], info[0]['company'], info[0]['rfc'], info[0]['phone'], info[0]['address']) cur.execute(sql, val)""".format(info) db_functions(code)
def setUp(self): global browser_name, creative code = """ campaign = {1} list_creatives = {0} for creative in list_creatives: cur.execute("DELETE FROM creatives WHERE campaign_id = %d AND name = '%s';" % (campaign,creative["name"])) """.format(list_creatives, campaign) creative = db_functions(code) self.driver = ModelConfig.driver_web browser_name = self.driver.capabilities['browserName'] if browser_name == "chrome": self.driver.maximize_window()
def setUp(self): global campaign, value self.driver = ModelConfig.driver_web self.driver.maximize_window() code = """ info = {0} client = "{1}" cur.execute("SELECT id FROM clients WHERE email = '%s'" % client) id_client = cur.fetchone()[0] cur.execute("DELETE FROM campaigns WHERE name = '%s' AND budget = %s AND objetive = %s" % (info[0]['name'], info[0]['budget'], info[0]['objetive'])) sql = "INSERT INTO campaigns (cam_code, name, industry, category, budget, url, redirect_url, script_snippet, " \ "objetive, status, dbm_client_secret, dbm_client_id, created_at, updated_at, client_id, utm_campaign, " \ "utm_source, ga_id, token_access_google_dbm) VALUES (%s, %s, %s, %s, %s, %s, '', '', %s, 1, '', '', %s, %s, " \ "%s, '', '', '', '') RETURNING name, industry, objetive" val = (info[0]['camcode'], info[0]['name'], info[0]['industry'], info[0]['category'], info[0]['budget'], info[0]['url'], info[0]['objetive'], strftime("%Y/%m/%d"), strftime("%Y/%m/%d"), id_client) cur.execute(sql, val) """.format(info, client) value = db_functions(code)[0]
def testuserempty(self): driver = self.driver info = json.loads(dashboard_success) code = """ info = {0} client = "{1}" for d_user in info: cur.execute("SELECT du.user_id FROM dashboard_users AS du JOIN users ON du.user_id = users.id WHERE " "email = '%s'" % (d_user['email'])) try: id = cur.fetchone()[0] cur.execute("DELETE FROM dashboard_users WHERE user_id=%s" % id) cur.execute("DELETE FROM admin_historicaluser WHERE history_user_id = %s" % id) cur.execute("DELETE FROM users WHERE id = %s" % id) except Exception as errorException: errorException cur.execute("INSERT INTO users (name, password, status, email, created_at, updated_at, is_active, is_client) VALUES " "('%s', '%s', 1, '%s', current_timestamp, current_timestamp, true, true) RETURNING id;" % (info[1]['name'], info[1]['password'], info[1]['email'])) id = cur.fetchone()[0] cur.execute("SELECT id FROM clients WHERE email = '%s'" % client) id_client = cur.fetchone()[0] cur.execute("INSERT INTO dashboard_users (client_id, user_id) VALUES (%s, %s)" % (id_client, id)) """.format(info, client) db_functions(code) login(self) driver.find_element_by_xpath('//*[@id="inputSrc"]').click() sleep(1) driver.find_element_by_xpath('//*[@id="search"]').send_keys(client) sleep(1) # view driver.find_element_by_xpath( '//*[@id="clienttable"]/tbody/tr[1]/td[5]/a[1]').click() sleep(3) # button_dashboard driver.find_element_by_xpath( '//*[@id="user-dashboard"]/div/div/div[4]/a[1]').click() sleep(3) # email driver.find_element_by_xpath('//*[@id="edit-dash-user-email"]').clear() driver.find_element_by_xpath( '//*[@id="edit-dash-user-email"]').send_keys((info[0]["email"])) # name driver.find_element_by_xpath('//*[@id="edit-dash-user-name"]').clear() driver.find_element_by_xpath( '//*[@id="edit-dash-user-name"]').send_keys((info[0]["name"])) sleep(3) # password driver.find_element_by_xpath( '//*[@id="edit-dash-user-status"]').click() driver.find_element_by_xpath( '//*[@id="edit-dash-user-status"]').send_keys((info[0]["status"])) # confirmation de password # save driver.find_element_by_xpath( '//*[@id="modal-edit-dashboard-user"]/div/div/div[3]/button' ).click() sleep(3) # asser self.assertEqual(info[0]["name"], driver.find_element_by_xpath( '//*[@id="user-dashboard"]/div/div/div[2]').text, msg=None) self.assertEqual(info[0]["email"], driver.find_element_by_xpath( '//*[@id="user-dashboard"]/div/div/div[1]').text, msg=None)
def testDeletedUsersSuccess(self): users = ''' [{"email" : "*****@*****.**", "password" : "2233445:", "confirm_password" : "2233445:", "name" : "Fernanda Rodriguez Martinez"}, {"email" : "*****@*****.**", "password" : "46546554?¡", "confirm_password" : "46546554?¡", "name" : "Cesar Perez Lopez"}, {"email" : "*****@*****.**", "password" : "97744552121?", "confirm_password" : "97744552121?", "name" : "Anita Rodriguez Perez"} ]''' info = json.loads(users) driver = self.driver rand = randint(0, len(info) - 1) code = """ #declaraciones de variables info = {0} rand = {1} #recorrer el JSON for user in info: cur.execute("DELETE FROM users WHERE email = '%s'" % user['email']) cur.execute("DELETE FROM admin_historicaluser WHERE email = '%s'" % user['email']) #print the returned value print(cur.rowcount) sql = 'INSERT INTO users (name, password, status, email, created_at, updated_at, is_active, is_client)' \ 'VALUES (%s, %s, %s, %s, current_timestamp, current_timestamp, %s, %s) returning email' val = (info[rand]['name'], info[rand]['password'], '1', info[rand]['email'], 'true', 'false') cur.execute(sql, val) """.format(info, rand) db_functions(code) login(self) time.sleep(3) time.sleep(3) driver.find_element_by_xpath( '//*[@id="sections-access"]/div[1]/a').click() time.sleep(2) # Find user driver.find_element_by_id('inputSrc').click() time.sleep(2) driver.find_element_by_xpath('//*[@id="search"] ').send_keys( info[rand]['email']) time.sleep(3) driver.find_element_by_xpath( '//*[@id="usertable"]/tbody/tr[1]/td[4]/a[2]/i').click() time.sleep(2) # Remove user driver.find_element_by_xpath( '//*[@id="modal-delete"]/div/div/div[3]/div[2]/button').click() time.sleep(4) driver.find_element_by_css_selector( '#form-confirm #input-confirmation').send_keys(info[rand]['email']) time.sleep(4) driver.find_element_by_xpath('//*[@id="btn-submit"]').click() time.sleep(4) # Screenshot path = "/users/screenshot/delete/" screenshot(self, path) driver.refresh() time.sleep(4) # Find user driver.find_element_by_id('inputSrc').click() time.sleep(2) driver.find_element_by_xpath('//*[@id="search"]').send_keys( info[rand]['email']) time.sleep(5) # Screenshot screenshot(self, path) # Compare self.assertEqual(driver.find_element_by_xpath( '//*[@id="usertable"]/tbody/tr[1]/td[1]').get_attribute( 'innerHTML'), info[rand]['email'], msg=None) time.sleep(5) self.assertEqual(driver.find_element_by_xpath( '//*[@id="usertable"]/tbody/tr[1]/td[2]').get_attribute( 'innerHTML'), info[rand]['name'], msg=None)