test-reporting 4.2.0__tar.gz → 4.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. {test_reporting-4.2.0 → test_reporting-4.3.0}/PKG-INFO +1 -1
  2. {test_reporting-4.2.0 → test_reporting-4.3.0}/reporting/exporters/pdf_exporter.py +67 -17
  3. {test_reporting-4.2.0 → test_reporting-4.3.0}/reporting/exporters/pptx_exporter.py +99 -24
  4. {test_reporting-4.2.0 → test_reporting-4.3.0}/reporting/exporters/xlsx_exporter.py +79 -0
  5. {test_reporting-4.2.0 → test_reporting-4.3.0}/reporting/monthly_report.py +30 -22
  6. {test_reporting-4.2.0 → test_reporting-4.3.0}/reporting/monthly_ui.py +1 -1
  7. test_reporting-4.3.0/reporting/report_insights.py +35 -0
  8. {test_reporting-4.2.0 → test_reporting-4.3.0}/reporting/run_source.py +25 -2
  9. {test_reporting-4.2.0 → test_reporting-4.3.0}/setup.py +1 -1
  10. {test_reporting-4.2.0 → test_reporting-4.3.0}/test_reporting.egg-info/PKG-INFO +1 -1
  11. {test_reporting-4.2.0 → test_reporting-4.3.0}/test_reporting.egg-info/SOURCES.txt +1 -0
  12. {test_reporting-4.2.0 → test_reporting-4.3.0}/tests/test_published_monthly_report.py +22 -5
  13. {test_reporting-4.2.0 → test_reporting-4.3.0}/LICENSE +0 -0
  14. {test_reporting-4.2.0 → test_reporting-4.3.0}/README.md +0 -0
  15. {test_reporting-4.2.0 → test_reporting-4.3.0}/reporting/__init__.py +0 -0
  16. {test_reporting-4.2.0 → test_reporting-4.3.0}/reporting/classifier.py +0 -0
  17. {test_reporting-4.2.0 → test_reporting-4.3.0}/reporting/cli.py +0 -0
  18. {test_reporting-4.2.0 → test_reporting-4.3.0}/reporting/config.py +0 -0
  19. {test_reporting-4.2.0 → test_reporting-4.3.0}/reporting/exporters/__init__.py +0 -0
  20. {test_reporting-4.2.0 → test_reporting-4.3.0}/reporting/plugin.py +0 -0
  21. {test_reporting-4.2.0 → test_reporting-4.3.0}/reporting/publisher.py +0 -0
  22. {test_reporting-4.2.0 → test_reporting-4.3.0}/reporting/storage.py +0 -0
  23. {test_reporting-4.2.0 → test_reporting-4.3.0}/reporting/templates/index.html +0 -0
  24. {test_reporting-4.2.0 → test_reporting-4.3.0}/reporting/templates/project.html +0 -0
  25. {test_reporting-4.2.0 → test_reporting-4.3.0}/reporting/templates/run.html +0 -0
  26. {test_reporting-4.2.0 → test_reporting-4.3.0}/setup.cfg +0 -0
  27. {test_reporting-4.2.0 → test_reporting-4.3.0}/test_reporting.egg-info/dependency_links.txt +0 -0
  28. {test_reporting-4.2.0 → test_reporting-4.3.0}/test_reporting.egg-info/entry_points.txt +0 -0
  29. {test_reporting-4.2.0 → test_reporting-4.3.0}/test_reporting.egg-info/requires.txt +0 -0
  30. {test_reporting-4.2.0 → test_reporting-4.3.0}/test_reporting.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: test-reporting
3
- Version: 4.2.0
3
+ Version: 4.3.0
4
4
  Summary: Multi-project test reporting dashboard — collect results locally or push to S3
5
5
  Home-page: https://github.com/amahdy77/test-reporting.git
6
6
  Author: Ashfaqur Mahdy
@@ -3,6 +3,7 @@ PDF Exporter for Monthly Reports
3
3
  """
4
4
  from pathlib import Path
5
5
  from typing import Dict, Any, List
6
+ from xml.sax.saxutils import escape
6
7
 
7
8
  try:
8
9
  from reportlab.lib.pagesizes import letter, A4
@@ -25,25 +26,36 @@ class PDFExporter:
25
26
  """Exports monthly report to PDF format."""
26
27
 
27
28
  def __init__(self):
29
+ self.navy = colors.HexColor('#142B49')
30
+ self.teal = colors.HexColor('#087E83')
31
+ self.ink = colors.HexColor('#1E293B')
32
+ self.muted = colors.HexColor('#64748B')
33
+ self.light = colors.HexColor('#F3F7FA')
34
+ self.border = colors.HexColor('#DCE5ED')
28
35
  self.styles = getSampleStyleSheet()
29
36
  self._setup_custom_styles()
30
37
 
31
38
  def _setup_custom_styles(self):
32
39
  """Setup custom paragraph styles."""
40
+ self.styles['Normal'].fontName = 'Helvetica'
41
+ self.styles['Normal'].fontSize = 10
42
+ self.styles['Normal'].leading = 15
43
+ self.styles['Normal'].textColor = self.ink
33
44
  self.styles.add(ParagraphStyle(
34
45
  name='CustomTitle',
35
46
  parent=self.styles['Heading1'],
36
- fontSize=24,
37
- textColor=colors.HexColor('#1a202c'),
47
+ fontSize=28,
48
+ leading=34,
49
+ textColor=self.navy,
38
50
  spaceAfter=30,
39
- alignment=TA_CENTER
51
+ alignment=TA_LEFT
40
52
  ))
41
53
 
42
54
  self.styles.add(ParagraphStyle(
43
55
  name='SectionTitle',
44
56
  parent=self.styles['Heading2'],
45
57
  fontSize=16,
46
- textColor=colors.HexColor('#2d3748'),
58
+ textColor=self.navy,
47
59
  spaceAfter=12,
48
60
  spaceBefore=20
49
61
  ))
@@ -52,14 +64,14 @@ class PDFExporter:
52
64
  name='MetricLabel',
53
65
  parent=self.styles['Normal'],
54
66
  fontSize=10,
55
- textColor=colors.HexColor('#718096')
67
+ textColor=self.muted
56
68
  ))
57
69
 
58
70
  self.styles.add(ParagraphStyle(
59
71
  name='MetricValue',
60
72
  parent=self.styles['Normal'],
61
73
  fontSize=18,
62
- textColor=colors.HexColor('#1a202c'),
74
+ textColor=self.ink,
63
75
  fontName='Helvetica-Bold'
64
76
  ))
65
77
 
@@ -77,7 +89,7 @@ class PDFExporter:
77
89
  rightMargin=72,
78
90
  leftMargin=72,
79
91
  topMargin=72,
80
- bottomMargin=18
92
+ bottomMargin=40
81
93
  )
82
94
 
83
95
  story = []
@@ -88,7 +100,7 @@ class PDFExporter:
88
100
 
89
101
  # Executive Summary
90
102
  if sections.get('summary', True):
91
- story.extend(self._create_summary_section(metrics['summary']))
103
+ story.extend(self._create_summary_section(metrics['summary'], metrics.get('highlights', [])))
92
104
  story.append(PageBreak())
93
105
 
94
106
  # Daily Trends
@@ -130,31 +142,60 @@ class PDFExporter:
130
142
  if sections.get('recommendations', True) and metrics.get('recommendations'):
131
143
  story.extend(self._create_recommendations_section(metrics['recommendations']))
132
144
 
133
- doc.build(story)
145
+ for element in story:
146
+ if isinstance(element, Table):
147
+ element.setStyle(TableStyle([
148
+ ('BACKGROUND', (0, 0), (-1, 0), self.navy),
149
+ ('ROWBACKGROUNDS', (0, 1), (-1, -1), [colors.white, self.light]),
150
+ ('GRID', (0, 0), (-1, -1), 0.35, self.border),
151
+ ('TOPPADDING', (0, 0), (-1, -1), 7),
152
+ ('BOTTOMPADDING', (0, 0), (-1, -1), 7),
153
+ ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'),
154
+ ]))
155
+ doc.build(story, onFirstPage=self._draw_page, onLaterPages=self._draw_page)
156
+
157
+ def _draw_page(self, canvas, doc):
158
+ width, height = A4
159
+ canvas.saveState()
160
+ canvas.setFillColor(self.navy)
161
+ canvas.rect(0, height - 13, width, 13, stroke=0, fill=1)
162
+ if doc.page > 1:
163
+ canvas.setFont('Helvetica-Bold', 9)
164
+ canvas.setFillColor(self.navy)
165
+ canvas.drawString(72, height - 40, 'TEST EXECUTION REVIEW')
166
+ canvas.setStrokeColor(self.border)
167
+ canvas.line(72, 36, width - 72, 36)
168
+ canvas.setFont('Helvetica', 8)
169
+ canvas.setFillColor(self.muted)
170
+ canvas.drawString(72, 23, 'QA REPORTING | Generated from published test runs')
171
+ canvas.drawRightString(width - 72, 23, f'{doc.page:02d}')
172
+ canvas.restoreState()
134
173
 
135
174
  def _create_title_page(self, report_meta, metrics):
136
175
  """Create title page."""
137
176
  story = []
138
177
 
139
- story.append(Spacer(1, 2*inch))
178
+ story.append(Spacer(1, 1.15*inch))
140
179
 
141
- title = Paragraph("📊 Monthly Test Report", self.styles['CustomTitle'])
180
+ story.append(Paragraph('QUALITY INTELLIGENCE / PERIOD REVIEW', self.styles['MetricLabel']))
181
+ story.append(Spacer(1, 0.18*inch))
182
+ title = Paragraph("Test Execution Report", self.styles['CustomTitle'])
142
183
  story.append(title)
143
184
  story.append(Spacer(1, 0.3*inch))
144
185
 
145
186
  date_range = Paragraph(
146
- f"{report_meta['start_date']} to {report_meta['end_date']}",
187
+ f"{report_meta['start_date']} — {report_meta['end_date']}",
147
188
  self.styles['Normal']
148
189
  )
149
190
  story.append(date_range)
150
191
  story.append(Spacer(1, 0.2*inch))
151
192
 
152
193
  project = Paragraph(
153
- f"Project: {report_meta['project']}",
194
+ f"<b>{escape(report_meta['project'])}</b>",
154
195
  self.styles['Normal']
155
196
  )
156
197
  story.append(project)
157
- story.append(Spacer(1, 1*inch))
198
+ story.append(Spacer(1, 0.75*inch))
158
199
 
159
200
  # Health score
160
201
  health_score = metrics['summary']['health_score']
@@ -173,17 +214,26 @@ class PDFExporter:
173
214
  story.append(health_text)
174
215
  story.append(Spacer(1, 0.2*inch))
175
216
 
176
- health_label = Paragraph("Health Score", self.styles['MetricLabel'])
217
+ health_label = Paragraph("TEST EXECUTION HEALTH", self.styles['MetricLabel'])
177
218
  story.append(health_label)
219
+ story.append(Spacer(1, 0.65*inch))
220
+ story.append(Paragraph(
221
+ f"Based on {metrics['summary']['total_tests']:,} test executions across "
222
+ f"{metrics['summary']['total_runs']:,} runs. This score reflects test outcomes, "
223
+ "not code coverage or product defect severity.", self.styles['Normal']))
178
224
 
179
225
  return story
180
226
 
181
- def _create_summary_section(self, summary):
227
+ def _create_summary_section(self, summary, highlights):
182
228
  """Create executive summary section."""
183
229
  story = []
184
230
 
185
231
  story.append(Paragraph("Executive Summary", self.styles['SectionTitle']))
186
232
  story.append(Spacer(1, 0.2*inch))
233
+ for insight in highlights:
234
+ story.append(Paragraph(escape(insight), self.styles['Normal']))
235
+ story.append(Spacer(1, 0.13*inch))
236
+ story.append(Spacer(1, 0.12*inch))
187
237
 
188
238
  # Create metrics table
189
239
  data = [
@@ -475,7 +525,7 @@ class PDFExporter:
475
525
  story.append(Spacer(1, 0.2*inch))
476
526
 
477
527
  for i, rec in enumerate(recommendations, 1):
478
- text = f"{i}. {rec}"
528
+ text = f"{i}. {escape(rec)}"
479
529
  p = Paragraph(text, self.styles['Normal'])
480
530
  story.append(p)
481
531
  story.append(Spacer(1, 0.15*inch))
@@ -11,6 +11,7 @@ try:
11
11
  from pptx.chart.data import CategoryChartData
12
12
  from pptx.enum.chart import XL_CHART_TYPE
13
13
  from pptx.dml.color import RGBColor
14
+ from pptx.enum.shapes import MSO_SHAPE
14
15
  except ImportError:
15
16
  raise ImportError(
16
17
  "python-pptx is required for PowerPoint export. "
@@ -29,6 +30,10 @@ class PowerPointExporter:
29
30
  'blue': RGBColor(49, 130, 206),
30
31
  'gray': RGBColor(113, 128, 150)
31
32
  }
33
+ self.navy = RGBColor(20, 43, 73)
34
+ self.teal = RGBColor(8, 126, 131)
35
+ self.light = RGBColor(244, 248, 251)
36
+ self.ink = RGBColor(38, 55, 74)
32
37
 
33
38
  def export(
34
39
  self,
@@ -47,7 +52,7 @@ class PowerPointExporter:
47
52
 
48
53
  # Slide 2: Executive Summary
49
54
  if sections.get('summary', True):
50
- self._add_summary_slide(prs, metrics['summary'])
55
+ self._add_summary_slide(prs, metrics['summary'], metrics.get('highlights', []))
51
56
 
52
57
  # Slide 3: Pass Rate Trend
53
58
  if sections.get('trends', True) and metrics.get('daily_trends'):
@@ -85,6 +90,7 @@ class PowerPointExporter:
85
90
  if sections.get('recommendations', True) and metrics.get('recommendations'):
86
91
  self._add_recommendations_slide(prs, metrics['recommendations'])
87
92
 
93
+ self._polish_deck(prs, report_meta)
88
94
  prs.save(str(output_path))
89
95
 
90
96
  def _add_title_slide(self, prs, report_meta, metrics):
@@ -94,7 +100,7 @@ class PowerPointExporter:
94
100
  # Title
95
101
  title_box = slide.shapes.add_textbox(Inches(1), Inches(2), Inches(8), Inches(1))
96
102
  title_frame = title_box.text_frame
97
- title_frame.text = "📊 Monthly Test Report"
103
+ title_frame.text = "Test Execution Report"
98
104
  title_para = title_frame.paragraphs[0]
99
105
  title_para.font.size = Pt(44)
100
106
  title_para.font.bold = True
@@ -133,13 +139,13 @@ class PowerPointExporter:
133
139
 
134
140
  label_box = slide.shapes.add_textbox(Inches(3.5), Inches(6), Inches(3), Inches(0.4))
135
141
  label_frame = label_box.text_frame
136
- label_frame.text = "Health Score"
142
+ label_frame.text = "Test Execution Health"
137
143
  label_para = label_frame.paragraphs[0]
138
144
  label_para.font.size = Pt(16)
139
145
  label_para.alignment = PP_ALIGN.CENTER
140
146
  label_para.font.color.rgb = self.colors['gray']
141
147
 
142
- def _add_summary_slide(self, prs, summary):
148
+ def _add_summary_slide(self, prs, summary, highlights):
143
149
  """Add executive summary slide."""
144
150
  slide = prs.slides.add_slide(prs.slide_layouts[5]) # Title only
145
151
 
@@ -155,7 +161,7 @@ class PowerPointExporter:
155
161
  ]
156
162
 
157
163
  x_start = 1
158
- y_pos = 2.5
164
+ y_pos = 1.5
159
165
  box_width = 1.8
160
166
  box_height = 1.5
161
167
  spacing = 0.2
@@ -182,27 +188,96 @@ class PowerPointExporter:
182
188
  label_para.alignment = PP_ALIGN.CENTER
183
189
  label_para.font.color.rgb = self.colors['gray']
184
190
 
185
- # Additional metrics
186
- additional = [
187
- f"Passed: {summary['total_passed']} | Failed: {summary['total_failed']}",
188
- f"Skipped: {summary.get('total_skipped', 0)}",
189
- (f"Detailed records: {summary.get('detail_count', 0)}"
190
- + (' (complete)' if summary.get('detail_complete') else ' (incomplete)')),
191
- (f"Previous period: {summary['previous_pass_rate']}% ({summary['pass_rate_change']:+.1f} points)"
192
- if summary.get('previous_pass_rate') is not None else 'Previous period: no data'),
193
- f"Trend: {summary['trend']}",
194
- f"Avg Duration: {summary['avg_duration']}s per run"
195
- ]
196
-
197
- y_text = 4.5
198
- for text in additional:
199
- text_box = slide.shapes.add_textbox(Inches(1), Inches(y_text), Inches(8), Inches(0.3))
191
+ label = slide.shapes.add_textbox(Inches(1), Inches(3.25), Inches(8), Inches(0.35))
192
+ label.text_frame.text = 'KEY FINDINGS'
193
+ label.text_frame.paragraphs[0].font.size = Pt(12)
194
+ label.text_frame.paragraphs[0].font.bold = True
195
+ label.text_frame.paragraphs[0].font.color.rgb = self.teal
196
+ y_text = 3.7
197
+ for finding in highlights[:4]:
198
+ text_box = slide.shapes.add_textbox(Inches(1), Inches(y_text), Inches(8), Inches(0.68))
200
199
  text_frame = text_box.text_frame
201
- text_frame.text = text
200
+ text_frame.word_wrap = True
201
+ text_frame.text = finding
202
202
  text_para = text_frame.paragraphs[0]
203
- text_para.font.size = Pt(14)
204
- text_para.alignment = PP_ALIGN.CENTER
205
- y_text += 0.4
203
+ text_para.font.size = Pt(15)
204
+ text_para.font.color.rgb = self.ink
205
+ y_text += 0.72
206
+ note = slide.shapes.add_textbox(Inches(1), Inches(6.68), Inches(8), Inches(0.28))
207
+ note.text_frame.text = 'Execution health reflects test outcomes, not coverage or defect severity.'
208
+ note.text_frame.paragraphs[0].font.size = Pt(9)
209
+ note.text_frame.paragraphs[0].font.color.rgb = self.colors['gray']
210
+
211
+ def _polish_deck(self, prs, report_meta):
212
+ """Apply one restrained visual system to every slide."""
213
+ for number, slide in enumerate(prs.slides, 1):
214
+ cover = number == 1
215
+ slide.background.fill.solid()
216
+ slide.background.fill.fore_color.rgb = self.navy if cover else self.light
217
+
218
+ bar = slide.shapes.add_shape(
219
+ MSO_SHAPE.RECTANGLE, Inches(0), Inches(0),
220
+ prs.slide_width, Inches(0.09))
221
+ bar.fill.solid()
222
+ bar.fill.fore_color.rgb = self.teal
223
+ bar.line.fill.background()
224
+
225
+ if cover:
226
+ for shape in slide.shapes:
227
+ if not shape.has_text_frame or shape == bar:
228
+ continue
229
+ for paragraph in shape.text_frame.paragraphs:
230
+ if shape.left < Inches(2) and shape.top < Inches(3):
231
+ paragraph.font.color.rgb = RGBColor(255, 255, 255)
232
+ elif paragraph.font.color.rgb == self.colors['gray']:
233
+ paragraph.font.color.rgb = RGBColor(193, 211, 224)
234
+ continue
235
+
236
+ if slide.shapes.title:
237
+ title = slide.shapes.title
238
+ title.left, title.top = Inches(0.6), Inches(0.35)
239
+ title.width, title.height = Inches(8.8), Inches(0.65)
240
+ paragraph = title.text_frame.paragraphs[0]
241
+ paragraph.font.name = 'Aptos Display'
242
+ paragraph.font.size = Pt(27)
243
+ paragraph.font.bold = True
244
+ paragraph.font.color.rgb = self.navy
245
+
246
+ for shape in slide.shapes:
247
+ if shape.has_chart:
248
+ chart = shape.chart
249
+ chart.chart_style = 10
250
+ if chart.chart_type == XL_CHART_TYPE.LINE:
251
+ chart.series[0].format.line.color.rgb = self.teal
252
+ chart.series[0].format.line.width = Pt(2.5)
253
+ elif chart.chart_type == XL_CHART_TYPE.COLUMN_STACKED:
254
+ for series, color in zip(chart.series, [self.teal, self.colors['red']]):
255
+ series.format.fill.solid()
256
+ series.format.fill.fore_color.rgb = color
257
+ if not shape.has_table:
258
+ continue
259
+ table = shape.table
260
+ for row_index, row in enumerate(table.rows):
261
+ for cell in row.cells:
262
+ cell.fill.solid()
263
+ cell.fill.fore_color.rgb = (
264
+ self.navy if row_index == 0 else
265
+ RGBColor(255, 255, 255) if row_index % 2 else self.light)
266
+ cell.margin_left = Inches(0.12)
267
+ cell.margin_right = Inches(0.08)
268
+ for paragraph in cell.text_frame.paragraphs:
269
+ paragraph.font.name = 'Aptos'
270
+ paragraph.font.color.rgb = (
271
+ RGBColor(255, 255, 255) if row_index == 0 else self.ink)
272
+
273
+ footer = slide.shapes.add_textbox(
274
+ Inches(0.6), Inches(7.14), Inches(8.8), Inches(0.23))
275
+ footer.text_frame.text = (
276
+ f"{report_meta['project']} | {report_meta['start_date']}–"
277
+ f"{report_meta['end_date']} {number:02d}"
278
+ )
279
+ footer.text_frame.paragraphs[0].font.size = Pt(9)
280
+ footer.text_frame.paragraphs[0].font.color.rgb = self.colors['gray']
206
281
 
207
282
  def _add_trend_slide(self, prs, daily_trends):
208
283
  """Add pass rate trend chart."""
@@ -79,7 +79,86 @@ class ExcelExporter:
79
79
  if sections.get('recommendations', True) and metrics.get('recommendations'):
80
80
  self._create_recommendations_sheet(wb, metrics['recommendations'])
81
81
 
82
+ self._polish_workbook(wb, metrics, report_meta)
82
83
  wb.save(str(output_path))
84
+
85
+ def _polish_workbook(self, wb, metrics, report_meta):
86
+ """Make the summary scannable and detail tabs usable for analysis."""
87
+ navy, teal, light, ink = '142B49', '087E83', 'F4F8FB', '26374A'
88
+ for ws in wb.worksheets:
89
+ ws.sheet_view.showGridLines = False
90
+ ws.sheet_properties.pageSetUpPr.fitToPage = True
91
+ ws.page_setup.fitToWidth = 1
92
+ ws.sheet_properties.tabColor = teal if ws.title == 'Summary' else navy
93
+ if ws.title == 'Summary':
94
+ continue
95
+ ws.freeze_panes = 'B2'
96
+ ws.auto_filter.ref = f'A1:{get_column_letter(ws.max_column)}{ws.max_row}'
97
+ ws.row_dimensions[1].height = 30
98
+ for cell in ws[1]:
99
+ cell.fill = PatternFill('solid', fgColor=navy)
100
+ cell.font = Font(name='Aptos', size=11, bold=True, color='FFFFFF')
101
+ cell.alignment = Alignment(vertical='center', horizontal='left')
102
+ for row in ws.iter_rows(min_row=2):
103
+ for cell in row:
104
+ if cell.value is None:
105
+ continue
106
+ cell.font = Font(name='Aptos', size=10, color=ink)
107
+ cell.alignment = Alignment(vertical='center')
108
+ if cell.fill.patternType is None and cell.row % 2 == 0:
109
+ cell.fill = PatternFill('solid', fgColor=light)
110
+ ws.print_options.horizontalCentered = True
111
+ ws.print_title_rows = '1:1'
112
+
113
+ if 'Summary' not in wb:
114
+ return
115
+ ws = wb['Summary']
116
+ ws.merge_cells('A1:D2')
117
+ ws['A1'] = 'TEST EXECUTION REPORT'
118
+ ws['A1'].fill = PatternFill('solid', fgColor=navy)
119
+ ws['A1'].font = Font(name='Aptos Display', size=22, bold=True, color='FFFFFF')
120
+ ws['A1'].alignment = Alignment(vertical='center', indent=1)
121
+ ws.row_dimensions[1].height = 27
122
+ ws.row_dimensions[2].height = 20
123
+ ws.column_dimensions['A'].width = 29
124
+ ws.column_dimensions['B'].width = 32
125
+ ws.column_dimensions['C'].width = 24
126
+ ws.column_dimensions['D'].width = 24
127
+ for row in (3, 4, 5):
128
+ ws[f'A{row}'].font = Font(name='Aptos', size=10, color='64748B', bold=True)
129
+ ws[f'B{row}'].font = Font(name='Aptos', size=10, color=ink)
130
+ ws.merge_cells('A7:D7')
131
+ ws['A7'].fill = PatternFill('solid', fgColor=teal)
132
+ ws['A7'].font = Font(name='Aptos', size=12, bold=True, color='FFFFFF')
133
+ ws['A7'].alignment = Alignment(vertical='center', indent=1)
134
+ ws.row_dimensions[7].height = 26
135
+ for row in range(8, 22):
136
+ ws.row_dimensions[row].height = 23
137
+ ws[f'A{row}'].font = Font(name='Aptos', size=10, color='64748B', bold=True)
138
+ ws[f'B{row}'].font = Font(name='Aptos', size=11, color=ink, bold=True)
139
+ if row % 2 == 0:
140
+ ws[f'A{row}'].fill = PatternFill('solid', fgColor=light)
141
+ if ws[f'B{row}'].fill.patternType is None:
142
+ ws[f'B{row}'].fill = PatternFill('solid', fgColor=light)
143
+ ws.merge_cells('A24:D24')
144
+ ws['A24'] = 'KEY FINDINGS'
145
+ ws['A24'].fill = PatternFill('solid', fgColor=teal)
146
+ ws['A24'].font = Font(name='Aptos', size=12, bold=True, color='FFFFFF')
147
+ ws['A24'].alignment = Alignment(vertical='center', indent=1)
148
+ ws.row_dimensions[24].height = 26
149
+ for row, finding in enumerate(metrics.get('highlights', []), 25):
150
+ ws.merge_cells(start_row=row, start_column=1, end_row=row, end_column=4)
151
+ cell = ws.cell(row, 1, finding)
152
+ cell.font = Font(name='Aptos', size=11, color=ink)
153
+ cell.alignment = Alignment(wrap_text=True, vertical='center', indent=1)
154
+ cell.fill = PatternFill('solid', fgColor=light if row % 2 else 'FFFFFF')
155
+ ws.row_dimensions[row].height = 36
156
+ note_row = max(30, 26 + len(metrics.get('highlights', [])))
157
+ ws.merge_cells(start_row=note_row, start_column=1, end_row=note_row, end_column=4)
158
+ note = ws.cell(note_row, 1, 'Execution health reflects test outcomes, not coverage or defect severity.')
159
+ note.font = Font(name='Aptos', size=9, italic=True, color='64748B')
160
+ ws.freeze_panes = 'A8'
161
+ ws.print_area = f'A1:D{note_row}'
83
162
 
84
163
  def _create_summary_sheet(self, wb, summary, report_meta):
85
164
  """Create summary sheet with key metrics."""
@@ -11,6 +11,7 @@ from collections import defaultdict
11
11
  from .config import ReportingConfig
12
12
  from .storage import TestResultStorage
13
13
  from .run_source import PublishedRunSource
14
+ from .report_insights import build_highlights
14
15
 
15
16
 
16
17
  class MonthlyReportGenerator:
@@ -68,22 +69,29 @@ class MonthlyReportGenerator:
68
69
  if project:
69
70
  print(f"[Monthly Report] Project filter: {project}")
70
71
 
71
- # Collect and calculate metrics
72
- data = self.collect_data(start_date, end_date, project)
73
- if not data['runs']:
74
- raise ValueError(f'No runs found for {project} from {start_date} to {end_date}')
75
- metrics = self.calculate_metrics(data, top_n)
72
+ # Read the current and comparison periods in one store pass.
76
73
  period_days = (end - start).days + 1
77
74
  previous_end = start - timedelta(days=1)
78
75
  previous_start = previous_end - timedelta(days=period_days - 1)
79
- previous = self.collect_data(previous_start.isoformat(), previous_end.isoformat(), project)
80
- previous_total = sum(r.get('total_tests', 0) for r in previous['runs'])
81
- previous_passed = sum(r.get('passed', 0) for r in previous['runs'])
76
+ combined = self.collect_data(previous_start.isoformat(), end_date, project)
77
+ current_ids = {r['id'] for r in combined['runs'] if r.get('timestamp', '')[:10] >= start_date}
78
+ previous_ids = {r['id'] for r in combined['runs'] if r.get('timestamp', '')[:10] < start_date}
79
+ data = {
80
+ 'runs': [r for r in combined['runs'] if r['id'] in current_ids],
81
+ 'results': [r for r in combined['results'] if r['run_id'] in current_ids],
82
+ }
83
+ previous_runs = [r for r in combined['runs'] if r['id'] in previous_ids]
84
+ if not data['runs']:
85
+ raise ValueError(f'No runs found for {project} from {start_date} to {end_date}')
86
+ metrics = self.calculate_metrics(data, top_n)
87
+ previous_total = sum(r.get('total_tests', 0) for r in previous_runs)
88
+ previous_passed = sum(r.get('passed', 0) for r in previous_runs)
82
89
  summary = metrics['summary']
83
- summary['previous_runs'] = len(previous['runs'])
90
+ summary['previous_runs'] = len(previous_runs)
84
91
  summary['previous_pass_rate'] = round(previous_passed / previous_total * 100, 1) if previous_total else None
85
92
  summary['pass_rate_change'] = (round(summary['pass_rate'] - summary['previous_pass_rate'], 1)
86
93
  if summary['previous_pass_rate'] is not None else None)
94
+ metrics['highlights'] = build_highlights(metrics)
87
95
 
88
96
  # Generate report metadata
89
97
  report_meta = {
@@ -604,53 +612,53 @@ class MonthlyReportGenerator:
604
612
  health_score = summary.get('health_score', 0)
605
613
  if health_score < 80:
606
614
  recommendations.append(
607
- f"🔴 Critical: Overall health score is {health_score}%. "
608
- "Immediate action required to improve test stability."
615
+ f"Critical: Test health score is {health_score}%. "
616
+ "Review the most frequent failures and confirm their causes."
609
617
  )
610
618
  elif health_score < 95:
611
619
  recommendations.append(
612
- f"🟡 Warning: Health score is {health_score}%. "
620
+ f"Watch: Test health score is {health_score}%. "
613
621
  "Focus on reducing failures to reach 95%+ target."
614
622
  )
615
623
  else:
616
624
  recommendations.append(
617
- f"✅ Excellent: Health score is {health_score}%. "
618
- "Maintain current quality standards."
625
+ f"Strong result: Test health score is {health_score}%. "
626
+ "Continue monitoring the pass rate and failure mix."
619
627
  )
620
628
 
621
629
  # Failure hotspot recommendations
622
630
  if len(failure_hotspots) > 0:
623
631
  top_3 = failure_hotspots[:3]
624
632
  recommendations.append(
625
- f"Fix top {len(top_3)} failure hotspots: " +
633
+ f"Investigate the top {len(top_3)} recorded failure hotspots: " +
626
634
  ", ".join(f"{h['test_name']} ({h['failure_count']} failures)" for h in top_3)
627
635
  )
628
636
 
629
637
  # Flaky test recommendations
630
638
  if len(flaky_tests) > 0:
631
639
  recommendations.append(
632
- f"Stabilize {len(flaky_tests)} flaky tests to improve reliability. "
633
- "Consider adding waits, improving selectors, or removing unstable tests."
640
+ f"Investigate {len(flaky_tests)} tests that both passed and failed across runs. "
641
+ "Check whether failures come from the product, environment, or test code."
634
642
  )
635
643
 
636
644
  # Performance recommendations
637
645
  if len(slowest_tests) > 0:
638
646
  top_slow = slowest_tests[0]
639
647
  recommendations.append(
640
- f"Optimize slowest test: {top_slow['test_name']} "
641
- f"(avg {top_slow['avg_duration']}s). Consider parallelization or reducing scope."
648
+ f"Review the slowest test: {top_slow['test_name']} "
649
+ f"(avg {top_slow['avg_duration']}s) for avoidable delays."
642
650
  )
643
651
 
644
652
  # Trend-based recommendations
645
653
  trend = summary.get('trend', '0%')
646
654
  if trend.startswith('-'):
647
655
  recommendations.append(
648
- f"⚠️ Quality is declining ({trend}). "
649
- "Review recent changes and increase test coverage."
656
+ f"Pass rate is declining ({trend}). "
657
+ "Review recent failures and changes to the test environment or product."
650
658
  )
651
659
  elif trend.startswith('+') and float(trend.replace('%', '').replace('+', '')) > 2:
652
660
  recommendations.append(
653
- f"📈 Quality is improving ({trend}). "
661
+ f"Pass rate is improving ({trend}). "
654
662
  "Continue current practices and share learnings with team."
655
663
  )
656
664
 
@@ -45,7 +45,7 @@ button {{margin-top:1.5rem;background:#1d4ed8;color:white;border:0;cursor:pointe
45
45
  <label><input type="checkbox" name="format" value="pptx" checked> PowerPoint</label>
46
46
  <label><input type="checkbox" name="format" value="xlsx" checked> Excel</label></div>
47
47
  <button type="submit" onclick="this.textContent='Generating…';">Generate and download</button></form>
48
- <p><small>Runs stay in S3. The generated files are downloaded to your computer.</small></p>
48
+ <p><small>Runs stay in S3. The ZIP downloads when generation finishes. Watch the PowerShell window for progress; large date ranges may take a while.</small></p>
49
49
  </main></body></html>'''.encode('utf-8')
50
50
 
51
51
 
@@ -0,0 +1,35 @@
1
+ """Short, evidence-based takeaways shared by all report formats."""
2
+
3
+
4
+ def build_highlights(metrics):
5
+ summary = metrics['summary']
6
+ highlights = [
7
+ f"{summary['pass_rate']:.1f}% pass rate across {summary['total_tests']:,} test executions "
8
+ f"in {summary['total_runs']:,} runs."
9
+ ]
10
+
11
+ change = summary.get('pass_rate_change')
12
+ if change is None:
13
+ highlights.append('No earlier runs are available for an equal-length comparison period.')
14
+ else:
15
+ direction = 'up' if change > 0 else 'down' if change < 0 else 'unchanged'
16
+ highlights.append(
17
+ f"Pass rate is {direction} {abs(change):.1f} percentage points "
18
+ f"from the previous period ({summary['previous_runs']:,} runs)."
19
+ )
20
+
21
+ hotspots = metrics.get('failure_hotspots') or []
22
+ if hotspots:
23
+ top = hotspots[0]
24
+ highlights.append(
25
+ f"Most frequent recorded test failure: {top['test_name']} in {top['file_name']} "
26
+ f"({top['failure_count']:,} failures)."
27
+ )
28
+ elif summary['total_failed'] == 0:
29
+ highlights.append('No failed test executions were recorded in this period.')
30
+
31
+ if not summary.get('detail_complete'):
32
+ highlights.append('Detailed test history is incomplete; test-level trends are omitted.')
33
+ elif metrics.get('flaky_tests'):
34
+ highlights.append(f"{len(metrics['flaky_tests'])} tests passed and failed across runs; review stability.")
35
+ return highlights
@@ -1,6 +1,7 @@
1
1
  """Read published run files without involving the local pytest database."""
2
2
 
3
3
  import json
4
+ from concurrent.futures import ThreadPoolExecutor
4
5
  from datetime import date
5
6
  from pathlib import Path
6
7
 
@@ -52,21 +53,43 @@ class PublishedRunSource:
52
53
  prefix = self._key('runs', project) + '/'
53
54
  pages = self._client().get_paginator('list_objects_v2').paginate(
54
55
  Bucket=self.config.S3_BUCKET, Prefix=prefix)
56
+ keys = []
55
57
  for page in pages:
56
58
  for entry in page.get('Contents', []):
57
59
  key = entry['Key']
58
60
  if not key.endswith('.json'):
59
61
  continue
60
- body = self._client().get_object(Bucket=self.config.S3_BUCKET, Key=key)['Body'].read()
61
- run = json.loads(body)
62
+ key_date = self._date_from_key(key)
63
+ if key_date is None or start <= key_date <= end:
64
+ keys.append(key)
65
+ print(f'[Monthly Report] Reading {len(keys)} published run file(s) for {project}')
66
+ def read_run(key):
67
+ body = self._client().get_object(Bucket=self.config.S3_BUCKET, Key=key)['Body'].read()
68
+ return json.loads(body)
69
+ with ThreadPoolExecutor(max_workers=8) as pool:
70
+ for run in pool.map(read_run, keys):
62
71
  if self._selected(run, project, start, end):
63
72
  yield run
64
73
  else:
65
74
  for path in sorted((self.config.STORE_PATH / 'runs' / project).glob('*.json')):
75
+ key_date = self._date_from_key(path.name)
76
+ if key_date is not None and not start <= key_date <= end:
77
+ continue
66
78
  run = json.loads(path.read_text(encoding='utf-8'))
67
79
  if self._selected(run, project, start, end):
68
80
  yield run
69
81
 
82
+ @staticmethod
83
+ def _date_from_key(key):
84
+ """Use publisher run IDs to skip out-of-range objects before download."""
85
+ stem = key.rsplit('/', 1)[-1].removesuffix('.json')
86
+ if '__' not in stem:
87
+ return None
88
+ try:
89
+ return date.fromisoformat(stem.rsplit('__', 1)[-1][:10])
90
+ except ValueError:
91
+ return None
92
+
70
93
  @staticmethod
71
94
  def _selected(run, project, start, end):
72
95
  if run.get('project_name') != project:
@@ -9,7 +9,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
9
9
 
10
10
  setup(
11
11
  name='test-reporting',
12
- version='4.2.0',
12
+ version='4.3.0',
13
13
  description='Multi-project test reporting dashboard — collect results locally or push to S3',
14
14
  long_description=long_description,
15
15
  long_description_content_type="text/markdown",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: test-reporting
3
- Version: 4.2.0
3
+ Version: 4.3.0
4
4
  Summary: Multi-project test reporting dashboard — collect results locally or push to S3
5
5
  Home-page: https://github.com/amahdy77/test-reporting.git
6
6
  Author: Ashfaqur Mahdy
@@ -9,6 +9,7 @@ reporting/monthly_report.py
9
9
  reporting/monthly_ui.py
10
10
  reporting/plugin.py
11
11
  reporting/publisher.py
12
+ reporting/report_insights.py
12
13
  reporting/run_source.py
13
14
  reporting/storage.py
14
15
  reporting/exporters/__init__.py
@@ -82,23 +82,30 @@ class PublishedMonthlyReportTests(unittest.TestCase):
82
82
  def paginate(self, **kwargs):
83
83
  if kwargs.get('Delimiter'):
84
84
  return [{'CommonPrefixes': [{'Prefix': 'prod/runs/Project A/'}]}]
85
- return [{'Contents': [{'Key': 'prod/runs/Project A/current.json'}]},
86
- {'Contents': [{'Key': 'prod/runs/Project A/other.txt'}]}]
85
+ return [{'Contents': [
86
+ {'Key': 'prod/runs/Project A/Project-A__suite__2025-01-01T100000.json'},
87
+ {'Key': 'prod/runs/Project A/Project-A__suite__2026-10-01T100000.json'},
88
+ ]}, {'Contents': [{'Key': 'prod/runs/Project A/other.txt'}]}]
87
89
 
88
90
  class Client:
91
+ def __init__(self):
92
+ self.downloaded = []
93
+
89
94
  def get_paginator(self, operation):
90
- self_operation = operation
91
- assert self_operation == 'list_objects_v2'
95
+ assert operation == 'list_objects_v2'
92
96
  return Paginator()
93
97
 
94
98
  def get_object(self, **kwargs):
99
+ self.downloaded.append(kwargs['Key'])
95
100
  return {'Body': io.BytesIO(json.dumps(run).encode())}
96
101
 
97
102
  config = SimpleNamespace(STORE_TYPE='s3', STORE_PATH=Path(self.tmp.name),
98
103
  S3_PREFIX='prod', S3_BUCKET='bucket', S3_REGION='us-east-1')
99
- source = PublishedRunSource(config, s3_client=Client())
104
+ client = Client()
105
+ source = PublishedRunSource(config, s3_client=client)
100
106
  self.assertEqual(source.projects(), ['Project A'])
101
107
  self.assertEqual(len(list(source.runs('Project A', '2026-10-01', '2026-10-01'))), 1)
108
+ self.assertEqual(client.downloaded, ['prod/runs/Project A/Project-A__suite__2026-10-01T100000.json'])
102
109
 
103
110
  def test_local_date_picker_lists_projects_and_rejects_bad_dates(self):
104
111
  server = ThreadingHTTPServer(('127.0.0.1', 0), make_handler(self.config))
@@ -133,6 +140,16 @@ class PublishedMonthlyReportTests(unittest.TestCase):
133
140
  output_dir=self.config.STORE_PATH / 'exports')
134
141
  self.assertEqual({p.suffix for p in files}, {'.pdf', '.pptx', '.xlsx'})
135
142
  self.assertTrue(all(p.stat().st_size > 0 for p in files))
143
+ from openpyxl import load_workbook
144
+ from pptx import Presentation
145
+ workbook = load_workbook(next(p for p in files if p.suffix == '.xlsx'))
146
+ self.assertEqual(workbook['Summary']['A24'].value, 'KEY FINDINGS')
147
+ self.assertIn('100.0% pass rate', workbook['Summary']['A25'].value)
148
+ self.assertEqual(workbook['Pass Rate Trend'].freeze_panes, 'B2')
149
+ deck = Presentation(next(p for p in files if p.suffix == '.pptx'))
150
+ summary_text = ' '.join(shape.text for shape in deck.slides[1].shapes if shape.has_text_frame)
151
+ self.assertIn('KEY FINDINGS', summary_text)
152
+ self.assertIn('100.0% pass rate', summary_text)
136
153
 
137
154
 
138
155
  if __name__ == '__main__':
File without changes
File without changes
File without changes