Best Python code snippet using SeleniumBase
test_testcase_manager.py
Source:test_testcase_manager.py
...16 {"guid":"anexecutionguid"})17 query = """DELETE FROM testcaseRunData WHERE guid = %(guid)s"""18 DatabaseManager('qa').execute_query_and_close(query,19 {"guid":'antestcaseguid'})20 def test_insert_execution_data(self):21 payload = ExecutionQueryPayload()22 payload.guid = "anexecutionguid"23 payload.execution_start_time = 123456789024 payload.username = "myself"25 self.manager.insert_execution_data(payload)26 query = """SELECT * FROM execution WHERE guid = %(guid)s"""27 results = DatabaseManager('qa').fetchone_query_and_close(query, {"guid":'anexecutionguid'})28 self.assertTrue(results[0] == 'anexecutionguid')29 self.assertTrue(results[1] == -1)30 self.assertTrue(results[2] == 'myself')31 self.assertTrue(results[3] == 1234567890)32 33 def test_update_execution_data(self):34 payload = ExecutionQueryPayload()35 payload.guid = "anexecutionguid"36 payload.execution_start_time = 123437 payload.username = "myself"38 self.manager.insert_execution_data(payload)39 self.manager.update_execution_data("anexecutionguid", 60)40 query = """SELECT * FROM execution WHERE guid = %(guid)s"""41 results = DatabaseManager('qa').fetchone_query_and_close(query, {"guid":'anexecutionguid'})42 self.assertTrue(results[0] == 'anexecutionguid')43 self.assertTrue(results[1] == 60)44 self.assertTrue(results[2] == 'myself')45 self.assertTrue(results[3] == 1234)46 def test_insert_test_case_data(self):47 payload = TestcaseDataPayload()48 payload.guid = "antestcaseguid"49 payload.testcaseAddress = self.id()50 payload.application = "python unittest"51 payload.execution_guid = "executionmachine"52 payload.runtime = 55...
DBWriter.py
Source:DBWriter.py
...23 cls.conn.commit()24 cur.close()25 cls.conn.close()26 @classmethod27 def insert_execution_data(cls, data_list):28 with cls.lock:29 try:30 succes_flg = True31 cur = cls.conn.cursor()32 sql = "INSERT INTO public.executions (id, size, exec_date, side, buy_child_order_acceptance_id, sell_child_order_acceptance_id, price) VALUES %s"33 val_list = []34 for d in data_list:35 t = (d[0], d[1], d[2], d[3], d[4], d[5], d[6])36 val_list.append(t)37 execute_values(cur, sql, val_list)38 cls.conn.commit()39 except psycopg2.Error as e:40 print("Error on DBWriter-insertExecutionData! :"+e)41 succes_flg = False42 finally:43 return succes_flg44 @classmethod45 def write_execution_data_thread(cls):46 while SystemFlg.SystemFlg.dbwriter_flg:47 if DBData.BTCExecutionData.get_num_data() >= 100:48 data = DBData.BTCExecutionData.get_all_executions()49 if cls.insert_execution_data(data):50 DBData.BTCExecutionData.initialize()51 else:52 print('error')53 time.sleep(0.1)54 @classmethod55 def start_write_execution_data(cls):56 print('started DBWriter')57 cls.initialize()58 th = threading.Thread(target=cls.write_execution_data_thread())59 th.start()60if __name__ == '__main__':...
mock_objects.py
Source:mock_objects.py
...35 def __init__(self):36 self.mock_execution_guid = 'roflexecution'37 self.mock_testcase_guid = 'rofltestcase'38 39 def insert_execution_data(self, data_payload):40 self.execution_db.update(data_payload.get_params())41 self.execution_db['guid'] = self.mock_execution_guid42 return self.mock_execution_guid43 def update_execution_data(self, guid, runtime):44 self.execution_db['runtime'] = runtime45 return self.mock_execution_guid46 def insert_testcase_data(self, data_payload):47 self.testcase_db.update(data_payload.get_params())48 self.execution_db['guid'] = self.mock_execution_guid49 return self.mock_execution_guid50 def update_testcase_data(self, data_payload):51 self.testcase_db.update(data_payload.get_params())52 self.execution_db['guid'] = self.mock_execution_guid53 return self.mock_execution_guid...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!