[report-exporter] Hot fixes
- GetTables() searches by substring, thus can produce multiple results. Add one more check to choose the right table. - If build failed without any test results, create test data with one test case 'jenkins' with status 'failed'. Change-Id: Ieda81ea9f7fea14d345920a33bf0cce1aa386eab
This commit is contained in:
parent
637a6c927f
commit
ecba69dab2
@ -58,13 +58,35 @@ class Build():
|
||||
job_info = J.get_job_info(self.name, depth=1)
|
||||
self.number = job_info["lastCompletedBuild"]["number"]
|
||||
else:
|
||||
self.number = number
|
||||
self.number = int(number)
|
||||
|
||||
self.build_data = J.get_build_info(self.name, self.number, depth=1)
|
||||
self.url = self.build_data["url"]
|
||||
|
||||
def test_data(self):
|
||||
return get_test_data(self.url)
|
||||
try:
|
||||
data = get_test_data(self.url)
|
||||
except Exception as e:
|
||||
logger.warning("No test data for {0}: {1}".format(
|
||||
self.url,
|
||||
e,
|
||||
))
|
||||
# If we failed to get any tests for the build, return
|
||||
# meta test case 'jenkins' with status 'failed'.
|
||||
data = {
|
||||
"suites": [
|
||||
{
|
||||
"cases": [
|
||||
{
|
||||
"className": "jenkins",
|
||||
"status": "failed"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
return data
|
||||
|
||||
def __str__(self):
|
||||
string = "\n".join([
|
||||
|
@ -31,20 +31,40 @@ class Document():
|
||||
|
||||
def get_page(self, name):
|
||||
tables = self.gspreadsheet.GetTables(name=name)
|
||||
if len(tables) > 0:
|
||||
logger.debug("Use worksheet {0}".format(name))
|
||||
else:
|
||||
|
||||
# GetTables by name searches by substring in the table name.
|
||||
# GetTables(name="smth") can return ["smth","smth_else"]
|
||||
# Thus we run additional check for table.name
|
||||
tables = [table for table in tables if table.name == name]
|
||||
|
||||
if len(tables) == 0:
|
||||
# Create new worksheet
|
||||
logger.debug("Create new worksheet {0}".format(name))
|
||||
self.gspreadsheet.client._GetSpreadsheetsClient().AddWorksheet(
|
||||
wrksh = self.gspreadsheet.client._GetSpreadsheetsClient().AddWorksheet(
|
||||
title=name,
|
||||
row_count=1,
|
||||
col_count=50,
|
||||
key=self.gspreadsheet.spreadsheet_key,
|
||||
)
|
||||
tables = self.gspreadsheet.GetTables(name=name)
|
||||
table = text_db.Table(
|
||||
name=name,
|
||||
worksheet_entry=wrksh,
|
||||
database_client=self.gspreadsheet.client,
|
||||
spreadsheet_key=self.gspreadsheet.spreadsheet_key
|
||||
)
|
||||
elif len(tables) == 1:
|
||||
table = tables[0]
|
||||
logger.debug("Use worksheet {0}".format(table.name))
|
||||
else:
|
||||
logger.error(
|
||||
"There are {0} tables named {1}".format(
|
||||
len(tables),
|
||||
name,
|
||||
)
|
||||
)
|
||||
raise
|
||||
|
||||
return Page(tables.pop())
|
||||
return Page(table)
|
||||
|
||||
|
||||
class Page():
|
||||
|
Loading…
Reference in New Issue
Block a user