How to use _get_test_keyval method in autotest

Best Python code snippet using autotest_python Github


Full Screen

...787 formatted_row += "%s " % word788 formatted_row += "\n"789 formatted_row += "\n"790 return formatted_row791 def _get_test_keyval(jobid, keyname, db, default=''):792 try:793 lines = []794 idx = db.execute('SELECT job_idx FROM tko_jobs WHERE '795 'afe_job_id=%s' % jobid)[0]796 test_indexes = db.execute('SELECT test_idx FROM tko_tests WHERE '797 'job_idx=%s' % idx)798 for i in test_indexes:799 rows = db.execute('SELECT value FROM tko_test_attributes '800 'WHERE test_idx=%s AND attribute="%s"' %801 (i[0], keyname))802 if rows:803 for row in rows:804 line = []805 for c in row:806 line.append(str(c))807 lines.append(" ".join(line))808 if lines:809 return lines[0]810 else:811 return default812 except Exception:813 return default814 stats = {}815 rows = _db.execute("""816 SELECT t.test, s.word, t.reason817 FROM tko_tests AS t, tko_jobs AS j, tko_status AS s818 WHERE t.job_idx = j.job_idx819 AND s.status_idx = t.status820 AND j.afe_job_id = %s821 """ % framework_tests = _find_framework_tests(rows)823 failed_rows = [r for r in rows if r[1] != 'GOOD']824 framework_tests_failed = _find_framework_tests(failed_rows)825 explicitly_failed_rows = [r for r in rows if r[1] == 'FAIL']826 warn_rows = [r for r in rows if r[1] == 'WARN']827 skipped_rows = [(r[0], r[1], '') for r in rows if r[1] == 'TEST_NA']828 passed_rows = [(r[0], r[1], '') for r in rows if r[1] == 'GOOD' and r[0] not in framework_tests]829 total_executed = len(rows) - len(framework_tests)830 total_failed = len(failed_rows) - len(framework_tests_failed)831 total_skipped = len(skipped_rows)832 if total_executed > 0:833 success_rate = 100 - ((total_failed / float(total_executed)) * 100)834 else:835 success_rate = 0836 stats['total_executed'] = total_executed837 stats['total_failed'] = total_failed838 stats['total_passed'] = total_executed - total_failed839 stats['total_skipped'] = total_skipped840 stats['success_rate'] = success_rate841 stats['fail_detail'] = _format_rows(explicitly_failed_rows)842 stats['warn_detail'] = _format_rows(warn_rows)843 stats['skip_detail'] = _format_rows(skipped_rows)844 stats['pass_detail'] = _format_rows(passed_rows)845 time_row = _db.execute("""846 SELECT started_time, finished_time847 FROM tko_jobs848 WHERE afe_job_id = %s849 """ % if time_row:851 t_begin, t_end = time_row[0]852 try:853 delta = t_end - t_begin854 minutes, seconds = divmod(delta.seconds, 60)855 hours, minutes = divmod(minutes, 60)856 stats['execution_time'] = ("%02d:%02d:%02d" %857 (hours, minutes, seconds))858 # One of t_end or t_begin are None859 except TypeError:860 stats['execution_time'] = '(could not determine)'861 else:862 stats['execution_time'] = '(none)'863 keyval_dict_list = []864 keyval_list = self.get_keyval_list()865 print "DBG: kv list obtained from get_keyval_list: %s" % keyval_list866 if keyval_list:867 for kv in keyval_list:868 keyval_dict = {}869 keyval_dict[kv] = _get_test_keyval(, kv, _db)870 keyval_dict_list.append(keyval_dict)871 stats['keyval_dict_list'] = keyval_dict_list872 return stats873 def get_keyval_list(self):874 raw = settings.get_value('SCHEDULER',875 'keyval_names_exibit_summary_mail',876 default="")877 keyval_list = re.split(r'[\s,;:]', raw)878 return [element for element in keyval_list if element]879 def set_status(self, status, update_queues=False):880 self.update_field('status', status)881 if update_queues:882 for queue_entry in self.get_host_queue_entries():883 queue_entry.set_status(status)...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:


You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?