How to use _find_framework_tests method in autotest

Best Python code snippet using autotest_python

scheduler_models.py

Source:scheduler_models.py Github

copy

Full Screen

...736 """737 Get test execution details for this job.738 :return: Dictionary with test execution details739 """740 def _find_framework_tests(rows):741 """742 Here we are looking for tests such as SERVER_JOB and CLIENT_JOB.*743 Those are autotest 'internal job' tests, so they should not be744 counted when evaluating the test stats.745 :param rows: List of rows (matrix) with database results.746 """747 job_test_pattern = re.compile('SERVER|CLIENT\\_JOB\.[\d]')748 test_jobs = []749 for r in rows:750 test_name = r[0]751 if job_test_pattern.match(test_name):752 test_jobs.append(test_name)753 return test_jobs754 def _format_rows(rows, max_length=75):755 """756 Format failure rows, so they are legible on the resulting email.757 :param rows: List of rows (matrix) with database results.758 :param field: Field of the stats dict we want to fill.759 :param max_length: Int with maximum length of a line printed.760 """761 formatted_row = ""762 status_translate = {"GOOD": "PASS", "TEST_NA": "SKIP"}763 if rows:764 label = rows[0][1]765 if label in status_translate.keys():766 label = status_translate[label]767 formatted_row += "%s (%s):\n" % (label, len(rows))768 for row in rows:769 # Add test name, status and count770 formatted_row += " %s\n" % (row[0])771 # start to add reasons772 if row[2]:773 reason = row[2].split()774 curr_length = 0775 formatted_row += " "776 for word in reason:777 previous_length = curr_length778 curr_length += len(word)779 if curr_length > max_length:780 curr_length = 0781 if previous_length != 0:782 formatted_row += "\n %s " % word783 else:784 # Corner case, len(word) > 75 char785 formatted_row += "%s\n " % word786 else: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 """ % self.id)822 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_failed...

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:

YouTube

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?

Helpful

NotHelpful