Merge ~pieq/oem-qa-autosummary:fix-1928768-reports-lists into ~pieq/oem-qa-autosummary:master

Proposed by Pierre Equoy
Status: Merged
Approved by: Pierre Equoy
Approved revision: d997144db77faba10f73eb452c5eafae3e652d3b
Merged at revision: 60c47da8da82a118c12c1bb02394a5f4d766ee26
Proposed branch: ~pieq/oem-qa-autosummary:fix-1928768-reports-lists
Merge into: ~pieq/oem-qa-autosummary:master
Diff against target: 78 lines (+23/-18)
2 files modified
autosummary/summary.py (+8/-3)
webapp/__init__.py (+15/-15)
Reviewer Review Type Date Requested Status
Vic Liu (community) Approve
Pierre Equoy Pending
Review via email: mp+403106@code.launchpad.net

Description of the change

See commit description for more info.

Tested locally using a given project and milestone, with the following parameters:

1.
- empty "Hardware Used for Testing"
- empty "C3 Full Test Report(s)"
- empty "C3 Stress Test Report(s)"

2.
- "Hardware Used for Testing": lots of empty lines
- "C3 Full Test Report(s)": several C3 submissions links
- empty "C3 Stress Test Report(s)"

3.
- "Hardware Used for Testing": names of devices with CID numbers.
- empty "C3 Full Test Report(s)"
- "C3 Stress Test Report(s)": several C3 submissions links

Worked fine in every cases.

To post a comment you must log in.
Revision history for this message
Vic Liu (zongminl) wrote :

I tested this MR with the following scenarios
1. Summary got generated without problem
- empty "Hardware Used for Testing"
- empty "C3 Full Test Report(s)"
- empty "C3 Stress Test Report(s)"
- empty "HTML Report"
- empty "Scope"

2. Summary got generated without problem
- "Hardware Used for Testing": CID with a few empty lines and spaces at the fron
- empty "C3 Full Test Report(s)"
- empty "C3 Stress Test Report(s)"
- empty "HTML Report"
- empty "Scope"

3. Summary got generated without problem
- empty "Hardware Used for Testing"
- "C3 Full Test Report(s)": Submission link with a few empty lines and spaces at the front
- empty "C3 Stress Test Report(s)"
- empty "HTML Report"
- empty "Scope"

4.
- empty "Hardware Used for Testing"
- empty "C3 Full Test Report(s)"
- "C3 Stress Test Report(s)": Some lines with spaces and a submission link with a few spaces at the front (as below)
" "
" "
" "
" https://certification.canonical.com/hardware/202103-28798/submission/212779/"
- empty "HTML Report"
- empty "Scope"

Some empty lines with bullet points showed up in the "C3 Stress Test Reports:" field in the summary generated.
Maybe we can add a .strip() at the end of .splitlines() for each line?

review: Needs Fixing
Revision history for this message
Vic Liu (zongminl) wrote :

Ah, I made a mistake, did not aware of the attribute of .splitlines() is a list and .strip() is not applicable on lists.

Revision history for this message
Vic Liu (zongminl) wrote :

Adding a .strip() to the end of "if line" could fix this problem

Revision history for this message
Pierre Equoy (pieq) wrote :

Good catch, Vic, thanks!

I use line.strip() twice in the comprehension lists:
- the first is to remove the spaces in non-emtpy lines (so that " https://blabla/ " becomes "https://blabla/")
- the second is to have lines with only space replaced by "", and therefore ignored when calling splitlines()

Revision history for this message
Vic Liu (zongminl) wrote :

I tested all my 4 scenarios again with the updated commit:

1. Summary got generated without problem
- empty "Hardware Used for Testing"
- empty "C3 Full Test Report(s)"
- empty "C3 Stress Test Report(s)"
- empty "HTML Report"
- empty "Scope"

2. Summary got generated without problem
- "Hardware Used for Testing": CID with a few empty lines and spaces at the fron
- empty "C3 Full Test Report(s)"
- empty "C3 Stress Test Report(s)"
- empty "HTML Report"
- empty "Scope"

3. Summary got generated without problem
- empty "Hardware Used for Testing"
- "C3 Full Test Report(s)": Submission link with a few empty lines and spaces at the front
- empty "C3 Stress Test Report(s)"
- empty "HTML Report"
- empty "Scope"

4. Summary got generated without problem
- empty "Hardware Used for Testing"
- empty "C3 Full Test Report(s)"
- "C3 Stress Test Report(s)": Some lines with spaces and a submission link with a few spaces at the front (as below)
" "
" "
" "
" https://certification.canonical.com/hardware/202103-28798/submission/212779/"
- empty "HTML Report"
- empty "Scope"

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/autosummary/summary.py b/autosummary/summary.py
2index ec6158e..9d3b2b9 100644
3--- a/autosummary/summary.py
4+++ b/autosummary/summary.py
5@@ -81,10 +81,15 @@ class Summary:
6 for bug in bugs:
7 if bug.owner in team.members:
8 # To exclude checkbox-related bugs from summary report
9- if any(pattern not in bug.title.lower() for pattern in check_pattern) and \
10- "checkbox" not in bug.bug.tags:
11+ if (
12+ any(pattern not in bug.title.lower() for pattern in check_pattern)
13+ and "checkbox" not in bug.bug.tags
14+ ):
15 if bug.milestone:
16- if bug.milestone.series_target == self.lp_milestone.series_target:
17+ if (
18+ bug.milestone.series_target
19+ == self.lp_milestone.series_target
20+ ):
21 new_bugs.append(bug)
22 else:
23 # No milestone/series defined yet, assuming it should be part of
24diff --git a/webapp/__init__.py b/webapp/__init__.py
25index 721ecc3..93f4e0d 100644
26--- a/webapp/__init__.py
27+++ b/webapp/__init__.py
28@@ -168,21 +168,21 @@ def generate_summary():
29 html_report=html_report,
30 scope=scope,
31 )
32- if hardware:
33- # Splitting each line and removing empty lines
34- hardware = [line for line in hardware.splitlines() if line]
35- if full_test_reports:
36- full_test_reports = [line for line in full_test_reports.splitlines() if line]
37- if stress_test_reports:
38- stress_test_reports = [
39- line for line in stress_test_reports.splitlines() if line
40- ]
41+ # Splitting each line, removing empty lines or lines with only spaces and
42+ # stripping non-empty lines to remove spaces at the beginning/end.
43+ hardware_list = [line.strip() for line in hardware.splitlines() if line.strip()]
44+ full_test_reports_list = [
45+ line.strip() for line in full_test_reports.splitlines() if line.strip()
46+ ]
47+ stress_test_reports_list = [
48+ line.strip() for line in stress_test_reports.splitlines() if line.strip()
49+ ]
50 return render_template(
51 "summary.html",
52 report=report,
53- hardware=hardware,
54- full_test_reports=full_test_reports,
55- stress_test_reports=stress_test_reports,
56+ hardware=hardware_list,
57+ full_test_reports=full_test_reports_list,
58+ stress_test_reports=stress_test_reports_list,
59 html_report=html_report,
60 scope=scope,
61 nb_critical_bugs=nb_critical_bugs,
62@@ -203,7 +203,9 @@ def add_test_status():
63 "c3_links": request.form.getlist("c3_links"),
64 }
65 try:
66- res = requests.post(f"{AUTO_TEST_STATUS_URL}:{AUTO_TEST_STATUS_PORT}/api/v1/status", json=status)
67+ res = requests.post(
68+ f"{AUTO_TEST_STATUS_URL}:{AUTO_TEST_STATUS_PORT}/api/v1/status", json=status
69+ )
70 response = res.json()
71 status_code = res.status_code
72 except requests.exceptions.ConnectionError:
73@@ -219,5 +221,3 @@ def add_test_status():
74 auto_test_status_url=AUTO_TEST_STATUS_URL,
75 auto_test_status_port=AUTO_TEST_STATUS_PORT,
76 )
77-
78-

Subscribers

People subscribed via source and target branches

to all changes: