test-reporting 4.4.2__tar.gz → 4.4.4__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 (32) hide show
  1. {test_reporting-4.4.2 → test_reporting-4.4.4}/PKG-INFO +4 -1
  2. {test_reporting-4.4.2 → test_reporting-4.4.4}/README.md +3 -0
  3. {test_reporting-4.4.2 → test_reporting-4.4.4}/reporting/__init__.py +1 -1
  4. {test_reporting-4.4.2 → test_reporting-4.4.4}/reporting/cli.py +23 -1
  5. test_reporting-4.4.4/reporting/coverage.py +115 -0
  6. {test_reporting-4.4.2 → test_reporting-4.4.4}/reporting/exporters/pdf_exporter.py +125 -17
  7. {test_reporting-4.4.2 → test_reporting-4.4.4}/reporting/exporters/pptx_exporter.py +41 -0
  8. {test_reporting-4.4.2 → test_reporting-4.4.4}/reporting/exporters/xlsx_exporter.py +31 -2
  9. {test_reporting-4.4.2 → test_reporting-4.4.4}/reporting/monthly_report.py +12 -1
  10. {test_reporting-4.4.2 → test_reporting-4.4.4}/reporting/templates/index.html +22 -0
  11. {test_reporting-4.4.2 → test_reporting-4.4.4}/reporting/templates/project.html +48 -0
  12. {test_reporting-4.4.2 → test_reporting-4.4.4}/setup.py +1 -1
  13. {test_reporting-4.4.2 → test_reporting-4.4.4}/test_reporting.egg-info/PKG-INFO +4 -1
  14. {test_reporting-4.4.2 → test_reporting-4.4.4}/test_reporting.egg-info/SOURCES.txt +1 -0
  15. {test_reporting-4.4.2 → test_reporting-4.4.4}/tests/test_published_monthly_report.py +114 -0
  16. {test_reporting-4.4.2 → test_reporting-4.4.4}/LICENSE +0 -0
  17. {test_reporting-4.4.2 → test_reporting-4.4.4}/reporting/classifier.py +0 -0
  18. {test_reporting-4.4.2 → test_reporting-4.4.4}/reporting/config.py +0 -0
  19. {test_reporting-4.4.2 → test_reporting-4.4.4}/reporting/exporters/__init__.py +0 -0
  20. {test_reporting-4.4.2 → test_reporting-4.4.4}/reporting/monthly_ui.py +0 -0
  21. {test_reporting-4.4.2 → test_reporting-4.4.4}/reporting/pdf_analysis.py +0 -0
  22. {test_reporting-4.4.2 → test_reporting-4.4.4}/reporting/plugin.py +0 -0
  23. {test_reporting-4.4.2 → test_reporting-4.4.4}/reporting/publisher.py +0 -0
  24. {test_reporting-4.4.2 → test_reporting-4.4.4}/reporting/report_insights.py +0 -0
  25. {test_reporting-4.4.2 → test_reporting-4.4.4}/reporting/run_source.py +0 -0
  26. {test_reporting-4.4.2 → test_reporting-4.4.4}/reporting/storage.py +0 -0
  27. {test_reporting-4.4.2 → test_reporting-4.4.4}/reporting/templates/run.html +0 -0
  28. {test_reporting-4.4.2 → test_reporting-4.4.4}/setup.cfg +0 -0
  29. {test_reporting-4.4.2 → test_reporting-4.4.4}/test_reporting.egg-info/dependency_links.txt +0 -0
  30. {test_reporting-4.4.2 → test_reporting-4.4.4}/test_reporting.egg-info/entry_points.txt +0 -0
  31. {test_reporting-4.4.2 → test_reporting-4.4.4}/test_reporting.egg-info/requires.txt +0 -0
  32. {test_reporting-4.4.2 → test_reporting-4.4.4}/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.4.2
3
+ Version: 4.4.4
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
@@ -254,6 +254,7 @@ dashboard_max_runs_per_suite = 50 # Run history per suite (default: 50)
254
254
  | Command | Description |
255
255
  |---|---|
256
256
  | `test-report publish` | Push latest test run to the store |
257
+ | `test-report publish-coverage` | Publish project-owned automation inventory counts |
257
258
  | `test-report deploy` | Deploy static dashboard HTML to the store (run once) |
258
259
  | `test-report open` | Open local dashboard in browser |
259
260
  | `test-report stats` | Show stats from latest run (reads local SQLite) |
@@ -322,6 +323,8 @@ retention_days = 90 # Keep 90 days of artifacts and data
322
323
 
323
324
  Generate a report for one project from its published S3 or local run history. PDF is the default stakeholder report; PowerPoint and Excel are optional exports. The local UI offers rolling date presets, all published history, and custom dates. Reports are downloaded locally and do not change the publishing pipeline.
324
325
 
326
+ Projects can also publish QA-maintained automation inventory counts with `test-report publish-coverage --config reporting-jenkins.ini --file coverage.json`. The dashboard and monthly reports show the resulting automation coverage separately from test pass rates. See [MONTHLY_REPORTS.md](MONTHLY_REPORTS.md#project-supplied-automation-coverage) for the file format and publishing steps.
327
+
325
328
  For AWS SSO setup, commands, date selection, and metric definitions, see [MONTHLY_REPORTS.md](MONTHLY_REPORTS.md).
326
329
 
327
330
  ---
@@ -213,6 +213,7 @@ dashboard_max_runs_per_suite = 50 # Run history per suite (default: 50)
213
213
  | Command | Description |
214
214
  |---|---|
215
215
  | `test-report publish` | Push latest test run to the store |
216
+ | `test-report publish-coverage` | Publish project-owned automation inventory counts |
216
217
  | `test-report deploy` | Deploy static dashboard HTML to the store (run once) |
217
218
  | `test-report open` | Open local dashboard in browser |
218
219
  | `test-report stats` | Show stats from latest run (reads local SQLite) |
@@ -281,6 +282,8 @@ retention_days = 90 # Keep 90 days of artifacts and data
281
282
 
282
283
  Generate a report for one project from its published S3 or local run history. PDF is the default stakeholder report; PowerPoint and Excel are optional exports. The local UI offers rolling date presets, all published history, and custom dates. Reports are downloaded locally and do not change the publishing pipeline.
283
284
 
285
+ Projects can also publish QA-maintained automation inventory counts with `test-report publish-coverage --config reporting-jenkins.ini --file coverage.json`. The dashboard and monthly reports show the resulting automation coverage separately from test pass rates. See [MONTHLY_REPORTS.md](MONTHLY_REPORTS.md#project-supplied-automation-coverage) for the file format and publishing steps.
286
+
284
287
  For AWS SSO setup, commands, date selection, and metric definitions, see [MONTHLY_REPORTS.md](MONTHLY_REPORTS.md).
285
288
 
286
289
  ---
@@ -3,4 +3,4 @@ Test Reporting System
3
3
  Automatic test result collection, analysis, and dashboard generation.
4
4
  """
5
5
 
6
- __version__ = "2.0.0"
6
+ __version__ = "4.4.4"
@@ -90,6 +90,24 @@ def deploy(config_file='reporting.ini'):
90
90
  print(f" test-report open")
91
91
 
92
92
 
93
+ def publish_coverage():
94
+ """Publish project-owned coverage counts independently of test runs."""
95
+ import argparse
96
+ from .coverage import CoverageStore
97
+
98
+ parser = argparse.ArgumentParser(description='Publish project automation coverage')
99
+ parser.add_argument('--config', default='reporting.ini', help='Project reporting config')
100
+ parser.add_argument('--file', required=True, help='Coverage JSON maintained by the project')
101
+ args = parser.parse_args(sys.argv[2:])
102
+ config = ReportingConfig(config_file=args.config)
103
+ if config.STORE_TYPE == 's3' and not config.S3_BUCKET:
104
+ parser.error('S3 coverage publishing requires s3_bucket in the config')
105
+ snapshot = CoverageStore(config).publish(args.file)
106
+ print(f"[Reporting] Automation coverage published for {snapshot['project_name']}: "
107
+ f"{snapshot['automated_items']}/{snapshot['total_items']} "
108
+ f"({snapshot['coverage_percent']}%) as of {snapshot['as_of']}")
109
+
110
+
93
111
  def open_dashboard():
94
112
  """Serve the local dashboard over HTTP and open it in a browser.
95
113
 
@@ -366,6 +384,8 @@ def monthly_report():
366
384
  help='Output format(s): pdf, pptx, xlsx (comma-separated; default: pdf)')
367
385
  parser.add_argument('--output', help='Output directory (default: ./reports)')
368
386
  parser.add_argument('--top-n', type=int, default=10, help='Number of items in top N lists')
387
+ parser.add_argument('--report-type', choices=['detailed', 'executive'], default='detailed',
388
+ help='Detailed report or PDF-only executive summary (default: detailed)')
369
389
  parser.add_argument('--config', default='reporting.ini', help='Config file path')
370
390
 
371
391
  args = parser.parse_args(sys.argv[2:])
@@ -407,7 +427,8 @@ def monthly_report():
407
427
  project=args.project,
408
428
  formats=formats,
409
429
  top_n=args.top_n,
410
- output_dir=output_dir
430
+ output_dir=output_dir,
431
+ report_type=args.report_type
411
432
  )
412
433
 
413
434
  print(f"\n[Monthly Report] Generated {len(files)} file(s):")
@@ -433,6 +454,7 @@ def main():
433
454
  """Main CLI entry point."""
434
455
  commands = {
435
456
  'publish': (publish, 'Push latest test run to the configured store'),
457
+ 'publish-coverage': (publish_coverage, 'Publish project automation coverage counts'),
436
458
  'deploy': (deploy, 'Deploy static dashboard HTML to the store (run once)'),
437
459
  'rebuild': (rebuild_dashboard, 'Rebuild data.json from existing run files'),
438
460
  'open': (open_dashboard, 'Open local dashboard in browser'),
@@ -0,0 +1,115 @@
1
+ """Project-supplied automation coverage snapshots, separate from test runs."""
2
+
3
+ import json
4
+ from datetime import date
5
+ from pathlib import Path
6
+
7
+
8
+ def validate_coverage(payload, project_name=None):
9
+ """Normalize counts so every presentation uses the same denominator."""
10
+ if not isinstance(payload, dict):
11
+ raise ValueError('Coverage input must be a JSON object')
12
+ project = project_name or payload.get('project_name')
13
+ if not isinstance(project, str) or not project.strip() or '/' in project or '\\' in project:
14
+ raise ValueError('Coverage requires a valid project name')
15
+ if payload.get('project_name') and payload['project_name'] != project:
16
+ raise ValueError('Coverage project_name must match reporting.ini')
17
+ try:
18
+ as_of = date.fromisoformat(payload['as_of']).isoformat()
19
+ except (KeyError, TypeError, ValueError) as exc:
20
+ raise ValueError('Coverage as_of must be a YYYY-MM-DD date') from exc
21
+ total = payload.get('total_items')
22
+ automated = payload.get('automated_items')
23
+ if (type(total) is not int or total < 1 or
24
+ type(automated) is not int or not 0 <= automated <= total):
25
+ raise ValueError('Coverage requires total_items > 0 and 0 <= automated_items <= total_items')
26
+ return {
27
+ 'schema_version': 1,
28
+ 'project_name': project,
29
+ 'as_of': as_of,
30
+ 'total_items': total,
31
+ 'automated_items': automated,
32
+ 'not_automated_items': total - automated,
33
+ 'coverage_percent': round(automated / total * 100, 1),
34
+ }
35
+
36
+
37
+ class CoverageStore:
38
+ def __init__(self, config, s3_client=None):
39
+ self.config = config
40
+ self._s3_client = s3_client
41
+
42
+ def _client(self):
43
+ if self._s3_client is None:
44
+ try:
45
+ import boto3
46
+ except ImportError as exc:
47
+ raise RuntimeError('Install test-reporting[s3] for S3 coverage') from exc
48
+ self._s3_client = boto3.client('s3', region_name=self.config.S3_REGION)
49
+ return self._s3_client
50
+
51
+ def _key(self, project, filename):
52
+ return '/'.join(part.strip('/') for part in
53
+ (self.config.S3_PREFIX, 'coverage', project, filename) if part)
54
+
55
+ def _read(self, project, filename):
56
+ if self.config.STORE_TYPE == 's3':
57
+ try:
58
+ body = self._client().get_object(
59
+ Bucket=self.config.S3_BUCKET, Key=self._key(project, filename))['Body'].read()
60
+ except Exception as exc:
61
+ code = getattr(exc, 'response', {}).get('Error', {}).get('Code')
62
+ if code in {'NoSuchKey', '404', 'NotFound'}:
63
+ return None
64
+ raise
65
+ return validate_coverage(json.loads(body), project)
66
+ path = self.config.STORE_PATH / 'coverage' / project / filename
67
+ return validate_coverage(json.loads(path.read_text(encoding='utf-8')), project) if path.exists() else None
68
+
69
+ def _write(self, snapshot, filename):
70
+ project = snapshot['project_name']
71
+ body = json.dumps(snapshot, indent=2).encode('utf-8')
72
+ if self.config.STORE_TYPE == 's3':
73
+ self._client().put_object(
74
+ Bucket=self.config.S3_BUCKET, Key=self._key(project, filename),
75
+ Body=body, ContentType='application/json', CacheControl='no-cache')
76
+ else:
77
+ path = self.config.STORE_PATH / 'coverage' / project / filename
78
+ path.parent.mkdir(parents=True, exist_ok=True)
79
+ path.write_bytes(body)
80
+
81
+ def publish(self, input_file):
82
+ """Store a dated snapshot and update the dashboard pointer if it is newest."""
83
+ payload = json.loads(Path(input_file).read_text(encoding='utf-8'))
84
+ snapshot = validate_coverage(payload, self.config.PROJECT_NAME)
85
+ project = snapshot['project_name']
86
+ self._write(snapshot, snapshot['as_of'] + '.json')
87
+ latest = self._read(project, 'latest.json')
88
+ if latest is None or snapshot['as_of'] >= latest['as_of']:
89
+ self._write(snapshot, 'latest.json')
90
+ return snapshot
91
+
92
+ def as_of(self, project, end_date):
93
+ """Latest project snapshot on or before the report end date."""
94
+ cutoff = date.fromisoformat(end_date)
95
+ if self.config.STORE_TYPE == 's3':
96
+ prefix = self._key(project, '') + '/'
97
+ pages = self._client().get_paginator('list_objects_v2').paginate(
98
+ Bucket=self.config.S3_BUCKET, Prefix=prefix)
99
+ names = (item['Key'][len(prefix):] for page in pages for item in page.get('Contents', []))
100
+ else:
101
+ folder = self.config.STORE_PATH / 'coverage' / project
102
+ names = (path.name for path in folder.glob('*.json')) if folder.exists() else ()
103
+ dates = []
104
+ for name in names:
105
+ if '/' in name or not name.endswith('.json') or name == 'latest.json':
106
+ continue
107
+ try:
108
+ day = date.fromisoformat(name[:-5])
109
+ except ValueError:
110
+ continue
111
+ if day <= cutoff:
112
+ dates.append(day)
113
+ if not dates:
114
+ return None
115
+ return self._read(project, max(dates).isoformat() + '.json')
@@ -5,7 +5,7 @@ from typing import Any, Dict
5
5
  from xml.sax.saxutils import escape
6
6
 
7
7
  try:
8
- from reportlab.graphics.shapes import Circle, Drawing, Line, Rect, String
8
+ from reportlab.graphics.shapes import Circle, Drawing, Line, Rect, String, Wedge
9
9
  from reportlab.lib import colors
10
10
  from reportlab.lib.enums import TA_CENTER, TA_LEFT
11
11
  from reportlab.lib.pagesizes import A4
@@ -62,27 +62,32 @@ class PDFExporter:
62
62
  report_meta: Dict[str, Any], output_path: Path):
63
63
  analysis = metrics['pdf_analysis']
64
64
  summary = metrics['summary']
65
+ executive = report_meta.get('report_type') == 'executive'
65
66
  doc = SimpleDocTemplate(
66
67
  str(output_path), pagesize=A4, leftMargin=49, rightMargin=49,
67
68
  topMargin=57, bottomMargin=48,
68
- title=f"Test Execution Report - {report_meta['project']}",
69
+ title=f"{'Executive Summary' if executive else 'Test Execution Report'} - {report_meta['project']}",
69
70
  author='QA Reporting')
70
- story = self._cover(report_meta, summary, analysis)
71
- story.append(PageBreak())
72
- if sections.get('summary', True):
73
- story.extend(self._overview(metrics, analysis))
74
- if sections.get('trends', True) and metrics.get('daily_trends'):
71
+ if executive:
72
+ story = self._executive_summary(metrics, report_meta, analysis)
73
+ else:
74
+ story = self._cover(report_meta, summary, analysis)
75
75
  story.append(PageBreak())
76
- story.extend(self._activity(metrics['daily_trends'], summary, analysis))
77
- if sections.get('failures', True):
78
- story.append(PageBreak())
79
- story.extend(self._failure_mix(metrics, analysis))
80
- if summary.get('detail_complete') and (
81
- sections.get('file_health', True) or sections.get('failures', True)):
82
- story.append(PageBreak())
83
- story.extend(self._file_breakdown(analysis, report_meta['top_n']))
76
+ if sections.get('summary', True):
77
+ story.extend(self._overview(metrics, analysis))
78
+ if sections.get('trends', True) and metrics.get('daily_trends'):
79
+ story.append(PageBreak())
80
+ story.extend(self._activity(metrics['daily_trends'], summary, analysis))
81
+ if sections.get('failures', True):
82
+ story.append(PageBreak())
83
+ story.extend(self._failure_mix(metrics, analysis))
84
+ if summary.get('detail_complete') and (
85
+ sections.get('file_health', True) or sections.get('failures', True)):
86
+ story.append(PageBreak())
87
+ story.extend(self._file_breakdown(analysis, report_meta['top_n']))
84
88
  self._project = report_meta['project']
85
89
  self._period = f"{report_meta['start_date']} to {report_meta['end_date']}"
90
+ self._running_title = 'EXECUTIVE SUMMARY' if executive else 'TEST EXECUTION REPORT'
86
91
  doc.build(story, onFirstPage=self._page, onLaterPages=self._page)
87
92
 
88
93
  def _page(self, canvas, doc):
@@ -93,7 +98,7 @@ class PDFExporter:
93
98
  if doc.page > 1:
94
99
  canvas.setFont('Helvetica-Bold', 8)
95
100
  canvas.setFillColor(self.navy)
96
- canvas.drawString(49, height - 34, 'TEST EXECUTION REPORT')
101
+ canvas.drawString(49, height - 34, self._running_title)
97
102
  canvas.setStrokeColor(self.border)
98
103
  canvas.line(49, 35, width - 49, 35)
99
104
  canvas.setFont('Helvetica', 7.5)
@@ -125,6 +130,107 @@ class PDFExporter:
125
130
  ]))
126
131
  return table
127
132
 
133
+ def _executive_summary(self, metrics, meta, analysis):
134
+ summary = metrics['summary']
135
+ story = [
136
+ self._p('QUALITY INTELLIGENCE / PERIOD REVIEW', 'SubTitle'),
137
+ self._p('Executive Summary', 'ReportTitle'),
138
+ self._p(meta['project'], 'SubTitle'),
139
+ self._p(f"{meta['start_date']} to {meta['end_date']}"),
140
+ Spacer(1, 17),
141
+ ]
142
+ cards = [
143
+ ('PASS RATE', f"{summary['pass_rate']}%"),
144
+ ('TEST EXECUTIONS', f"{analysis['total']:,}"),
145
+ ('PUBLISHED RUNS', f"{summary['total_runs']:,}"),
146
+ ]
147
+ card_data = [[self._p(label, 'Small') for label, _ in cards],
148
+ [self._p(value, 'ReportTitle') for _, value in cards]]
149
+ card_table = Table(card_data, colWidths=[165, 165, 165], hAlign='LEFT')
150
+ card_table.setStyle(TableStyle([
151
+ ('BACKGROUND', (0, 0), (-1, -1), self.light),
152
+ ('BOX', (0, 0), (-1, -1), 0.5, self.border),
153
+ ('LEFTPADDING', (0, 0), (-1, -1), 12),
154
+ ('TOPPADDING', (0, 0), (-1, 0), 11),
155
+ ('BOTTOMPADDING', (0, 1), (-1, 1), 8),
156
+ ]))
157
+ story.extend([card_table, Spacer(1, 14)])
158
+ previous = ('No earlier runs' if summary['previous_pass_rate'] is None else
159
+ f"{summary['pass_rate_change']:+.1f} points vs {summary['previous_pass_rate']}% previously")
160
+ rows = [
161
+ ('Previous period', previous),
162
+ ('Failed / skipped', f"{analysis['failed']:,} / {analysis['skipped']:,} executions"),
163
+ ('Runs without failures',
164
+ f"{analysis['clean_runs']:,} of {summary['total_runs']:,} ({analysis['clean_run_rate']}%)"),
165
+ ('Activity', f"{analysis['active_days']:,} active days; "
166
+ f"{analysis['runs_per_active_day']} runs per active day"),
167
+ ('Average run duration', f"{summary['avg_duration']} seconds"),
168
+ ]
169
+ if summary.get('detail_complete'):
170
+ distinct_cases = sum(file['case_count'] for file in analysis['files'])
171
+ rows.append(('Distinct test cases observed', f'{distinct_cases:,} in selected runs'))
172
+ if metrics.get('failure_types'):
173
+ leading = metrics['failure_types'][0]
174
+ rows.append(('Most common failure type',
175
+ f"{leading['type']} ({leading['count']:,} failed executions)"))
176
+ story.extend([
177
+ self._p('At a glance', 'SectionTitle'),
178
+ self._table(['Measure', 'Period result'], rows, [160, 335]),
179
+ Spacer(1, 13),
180
+ self._p('Execution outcomes', 'SubTitle'),
181
+ self._p('Passed, failed and skipped shares of all recorded executions.', 'Small'),
182
+ Spacer(1, 4), self._outcome_chart(analysis),
183
+ ])
184
+ story.extend(self._coverage_section(metrics.get('coverage')))
185
+ daily = metrics.get('daily_trends', [])[-12:]
186
+ if len(daily) > 1:
187
+ story.extend([
188
+ Spacer(1, 8), self._p('Recent active days: pass rate', 'SubTitle'),
189
+ self._p('Most recent 12 active days; period totals above include every selected run.', 'Small'),
190
+ self._series_chart(daily, 'pass_rate', 100, self.teal, '%'),
191
+ ])
192
+ story.extend([Spacer(1, 9), self._p('Key observations', 'SubTitle')])
193
+ for insight in metrics.get('highlights', [])[:3]:
194
+ story.extend([self._p(insight), Spacer(1, 4)])
195
+ if not summary.get('detail_complete'):
196
+ story.extend([Spacer(1, 4), self._p(
197
+ 'Some run files lack full test-level detail. Test-specific observations are omitted.', 'Small')])
198
+ story.extend([Spacer(1, 5), self._p(
199
+ 'Source: published automated test runs for this project and period. '
200
+ 'Coverage, when supplied, comes from a separate project-maintained inventory.', 'Small')])
201
+ return story
202
+
203
+ def _coverage_section(self, coverage):
204
+ story = [Spacer(1, 10), self._p('Automation coverage', 'SubTitle')]
205
+ if coverage is None:
206
+ story.append(self._p('No project-supplied coverage snapshot is available on or before the report end date.',
207
+ 'Small'))
208
+ return story
209
+ rate = coverage['coverage_percent']
210
+ chart = Drawing(495, 138)
211
+ chart.add(Circle(70, 69, 57, fillColor=self.border, strokeColor=None))
212
+ if rate >= 100:
213
+ chart.add(Circle(70, 69, 57, fillColor=self.teal, strokeColor=None))
214
+ elif rate > 0:
215
+ chart.add(Wedge(70, 69, 57, 90, 90 + 360 * rate / 100,
216
+ fillColor=self.teal, strokeColor=None))
217
+ chart.add(Circle(70, 69, 41, fillColor=colors.white, strokeColor=None))
218
+ chart.add(String(70, 70, f'{rate:.1f}%', fontName='Helvetica-Bold', fontSize=18,
219
+ fillColor=self.navy, textAnchor='middle'))
220
+ chart.add(String(70, 53, 'automated', fontName='Helvetica', fontSize=8,
221
+ fillColor=self.muted, textAnchor='middle'))
222
+ chart.add(String(160, 100, f"{coverage['automated_items']:,} automated items",
223
+ fontName='Helvetica-Bold', fontSize=12, fillColor=self.navy))
224
+ chart.add(String(160, 77, f"{coverage['not_automated_items']:,} not automated items",
225
+ fontName='Helvetica', fontSize=10, fillColor=self.ink))
226
+ chart.add(String(160, 54, f"{coverage['total_items']:,} total tracked items",
227
+ fontName='Helvetica', fontSize=10, fillColor=self.ink))
228
+ chart.add(String(160, 28, f"Project inventory as of {coverage['as_of']}",
229
+ fontName='Helvetica', fontSize=9, fillColor=self.muted))
230
+ story.extend([self._p('Automated items / total tracked items. Supplied by the project; '
231
+ 'separate from execution pass rate.', 'Small'), Spacer(1, 5), chart])
232
+ return story
233
+
128
234
  def _cover(self, meta, summary, analysis):
129
235
  story = [Spacer(1, 1.15 * inch), self._p('QUALITY INTELLIGENCE / PERIOD REVIEW', 'SubTitle'),
130
236
  Spacer(1, 12), self._p('Test Execution Report', 'ReportTitle'),
@@ -150,7 +256,8 @@ class PDFExporter:
150
256
  self._p('What this report measures', 'SubTitle'),
151
257
  self._p('Results from published automated test runs for one project and the selected period. '
152
258
  'Pass rate is passed executions divided by all executions, including skipped tests. '
153
- 'These measures describe observed test execution, not product coverage or defect severity.'),
259
+ 'Execution measures describe observed tests. Automation coverage, when supplied, '
260
+ 'comes from a separate project inventory.'),
154
261
  Spacer(1, 12),
155
262
  self._p('Generated from run history; individual test measures appear only when detailed '
156
263
  'records cover all passed and failed executions.', 'Small')])
@@ -185,6 +292,7 @@ class PDFExporter:
185
292
  story.extend([Spacer(1, 16), self._p('Execution outcome mix', 'SubTitle'),
186
293
  self._p('Share of all test executions by outcome. The denominator includes skipped tests.', 'Small'),
187
294
  Spacer(1, 6), self._outcome_chart(analysis)])
295
+ story.extend(self._coverage_section(metrics.get('coverage')))
188
296
  if not summary.get('detail_complete'):
189
297
  story.extend([Spacer(1, 12), self._p('Data completeness', 'SubTitle'),
190
298
  self._p('Some published runs do not contain full test-level detail. File and test case '
@@ -53,6 +53,8 @@ class PowerPointExporter:
53
53
  # Slide 2: Executive Summary
54
54
  if sections.get('summary', True):
55
55
  self._add_summary_slide(prs, metrics['summary'], metrics.get('highlights', []))
56
+ if metrics.get('coverage'):
57
+ self._add_coverage_slide(prs, metrics['coverage'])
56
58
 
57
59
  # Slide 3: Pass Rate Trend
58
60
  if sections.get('trends', True) and metrics.get('daily_trends'):
@@ -204,6 +206,45 @@ class PowerPointExporter:
204
206
  note.text_frame.paragraphs[0].font.size = Pt(9)
205
207
  note.text_frame.paragraphs[0].font.color.rgb = self.colors['gray']
206
208
 
209
+ def _add_coverage_slide(self, prs, coverage):
210
+ slide = prs.slides.add_slide(prs.slide_layouts[5])
211
+ slide.shapes.title.text = 'Automation Coverage'
212
+ data = CategoryChartData()
213
+ data.categories = ['Automated', 'Not automated']
214
+ data.add_series('Tracked items',
215
+ (coverage['automated_items'], coverage['not_automated_items']))
216
+ chart = slide.shapes.add_chart(
217
+ XL_CHART_TYPE.DOUGHNUT, Inches(0.8), Inches(1.4),
218
+ Inches(4.3), Inches(4.4), data).chart
219
+ chart.has_legend = True
220
+ chart.legend.include_in_layout = False
221
+ chart.plots[0].hole_size = 72
222
+ for point, color in zip(chart.series[0].points,
223
+ (self.teal, RGBColor(220, 229, 237))):
224
+ point.format.fill.solid()
225
+ point.format.fill.fore_color.rgb = color
226
+ details = slide.shapes.add_textbox(Inches(5.4), Inches(1.85),
227
+ Inches(3.9), Inches(3.8)).text_frame
228
+ details.text = f"{coverage['coverage_percent']:.1f}% automated"
229
+ details.paragraphs[0].font.size = Pt(30)
230
+ details.paragraphs[0].font.bold = True
231
+ details.paragraphs[0].font.color.rgb = self.teal
232
+ for text in (
233
+ f"{coverage['automated_items']:,} automated items",
234
+ f"{coverage['not_automated_items']:,} not automated items",
235
+ f"{coverage['total_items']:,} total tracked items",
236
+ f"Project inventory as of {coverage['as_of']}"):
237
+ paragraph = details.add_paragraph()
238
+ paragraph.text = text
239
+ paragraph.font.size = Pt(17)
240
+ paragraph.font.color.rgb = self.ink
241
+ paragraph.space_before = Pt(14)
242
+ note = slide.shapes.add_textbox(Inches(0.8), Inches(6.35),
243
+ Inches(8.7), Inches(0.35))
244
+ note.text_frame.text = 'Project-supplied inventory; separate from test execution pass rate.'
245
+ note.text_frame.paragraphs[0].font.size = Pt(11)
246
+ note.text_frame.paragraphs[0].font.color.rgb = self.colors['gray']
247
+
207
248
  def _polish_deck(self, prs, report_meta):
208
249
  """Apply one restrained visual system to every slide."""
209
250
  for number, slide in enumerate(prs.slides, 1):
@@ -6,7 +6,7 @@ from typing import Dict, Any, List
6
6
 
7
7
  try:
8
8
  from openpyxl import Workbook
9
- from openpyxl.chart import LineChart, PieChart, BarChart, Reference
9
+ from openpyxl.chart import LineChart, PieChart, BarChart, DoughnutChart, Reference
10
10
  from openpyxl.styles import Font, PatternFill, Alignment, Border, Side
11
11
  from openpyxl.utils import get_column_letter
12
12
  except ImportError:
@@ -46,6 +46,8 @@ class ExcelExporter:
46
46
  # Sheet 1: Summary
47
47
  if sections.get('summary', True):
48
48
  self._create_summary_sheet(wb, metrics['summary'], report_meta)
49
+ if metrics.get('coverage'):
50
+ self._create_coverage_sheet(wb, metrics['coverage'])
49
51
 
50
52
  # Sheet 2: Daily Trends
51
53
  if sections.get('trends', True) and metrics.get('daily_trends'):
@@ -128,7 +130,7 @@ class ExcelExporter:
128
130
  ws['A7'].font = Font(name='Aptos', size=12, bold=True, color='FFFFFF')
129
131
  ws['A7'].alignment = Alignment(vertical='center', indent=1)
130
132
  ws.row_dimensions[7].height = 26
131
- for row in range(8, 22):
133
+ for row in range(8, 23):
132
134
  ws.row_dimensions[row].height = 23
133
135
  ws[f'A{row}'].font = Font(name='Aptos', size=10, color='64748B', bold=True)
134
136
  ws[f'B{row}'].font = Font(name='Aptos', size=11, color=ink, bold=True)
@@ -153,8 +155,35 @@ class ExcelExporter:
153
155
  ws.merge_cells(start_row=note_row, start_column=1, end_row=note_row, end_column=4)
154
156
  note = ws.cell(note_row, 1, 'Execution health reflects test outcomes, not coverage or defect severity.')
155
157
  note.font = Font(name='Aptos', size=9, italic=True, color='64748B')
158
+ coverage = metrics.get('coverage')
159
+ if coverage:
160
+ ws['A22'] = 'Automation Coverage'
161
+ ws['B22'] = f"{coverage['coverage_percent']}%"
162
+ ws['C22'] = f"{coverage['automated_items']} of {coverage['total_items']} items"
163
+ ws['D22'] = f"As of {coverage['as_of']}"
164
+ ws['B22'].font = Font(name='Aptos', size=11, color=teal, bold=True)
156
165
  ws.freeze_panes = 'A8'
157
166
  ws.print_area = f'A1:D{note_row}'
167
+
168
+ def _create_coverage_sheet(self, wb, coverage):
169
+ ws = wb.create_sheet('Automation Coverage')
170
+ ws['A1'] = 'AUTOMATION COVERAGE'
171
+ ws['A2'] = f"Project inventory as of {coverage['as_of']}"
172
+ ws['A3'] = 'Automated items / total tracked items'
173
+ ws['B3'] = coverage['coverage_percent'] / 100
174
+ ws['B3'].number_format = '0.0%'
175
+ ws['A5'], ws['B5'] = 'Automated', coverage['automated_items']
176
+ ws['A6'], ws['B6'] = 'Not automated', coverage['not_automated_items']
177
+ ws['A7'], ws['B7'] = 'Total tracked', coverage['total_items']
178
+ ws['A9'] = 'Project-supplied inventory; separate from test execution pass rate.'
179
+ ws.column_dimensions['A'].width = 54
180
+ ws.column_dimensions['B'].width = 18
181
+ chart = DoughnutChart()
182
+ chart.title = 'Items with automation'
183
+ chart.holeSize = 72
184
+ chart.add_data(Reference(ws, min_col=2, min_row=5, max_row=6), titles_from_data=False)
185
+ chart.set_categories(Reference(ws, min_col=1, min_row=5, max_row=6))
186
+ ws.add_chart(chart, 'D4')
158
187
 
159
188
  def _create_summary_sheet(self, wb, summary, report_meta):
160
189
  """Create summary sheet with key metrics."""
@@ -10,6 +10,7 @@ from collections import defaultdict
10
10
  from .config import ReportingConfig
11
11
  from .run_source import PublishedRunSource
12
12
  from .report_insights import build_highlights
13
+ from .coverage import CoverageStore
13
14
 
14
15
 
15
16
  class MonthlyReportGenerator:
@@ -27,7 +28,8 @@ class MonthlyReportGenerator:
27
28
  formats: List[str] = None,
28
29
  sections: Dict[str, bool] = None,
29
30
  top_n: int = 10,
30
- output_dir: Optional[Path] = None
31
+ output_dir: Optional[Path] = None,
32
+ report_type: str = 'detailed'
31
33
  ) -> List[Path]:
32
34
  """
33
35
  Generate monthly report in specified formats.
@@ -40,6 +42,7 @@ class MonthlyReportGenerator:
40
42
  sections: Dict of section names to include/exclude
41
43
  top_n: Number of items to show in top N lists
42
44
  output_dir: Output directory (defaults to temp)
45
+ report_type: 'detailed' or 'executive' (PDF only)
43
46
 
44
47
  Returns:
45
48
  List of generated file paths
@@ -53,6 +56,10 @@ class MonthlyReportGenerator:
53
56
  formats = formats or ['pdf']
54
57
  if not set(formats) <= {'pptx', 'xlsx', 'pdf'}:
55
58
  raise ValueError('Formats must be pptx, xlsx, or pdf')
59
+ if report_type not in {'detailed', 'executive'}:
60
+ raise ValueError('Report type must be detailed or executive')
61
+ if report_type == 'executive' and formats != ['pdf']:
62
+ raise ValueError('Executive summary is available as PDF only')
56
63
  sections = sections or {}
57
64
  output_dir = output_dir or Path.cwd() / 'reports'
58
65
  output_dir.mkdir(parents=True, exist_ok=True)
@@ -84,6 +91,7 @@ class MonthlyReportGenerator:
84
91
  summary['pass_rate_change'] = (round(summary['pass_rate'] - summary['previous_pass_rate'], 1)
85
92
  if summary['previous_pass_rate'] is not None else None)
86
93
  metrics['highlights'] = build_highlights(metrics)
94
+ metrics['coverage'] = CoverageStore(self.config).as_of(project, end_date)
87
95
 
88
96
  # Generate report metadata
89
97
  report_meta = {
@@ -92,6 +100,7 @@ class MonthlyReportGenerator:
92
100
  'project': project or 'All Projects',
93
101
  'generated_at': datetime.now().isoformat(),
94
102
  'top_n': top_n,
103
+ 'report_type': report_type,
95
104
  }
96
105
 
97
106
  # Generate each format
@@ -120,6 +129,8 @@ class MonthlyReportGenerator:
120
129
  from .pdf_analysis import build_pdf_analysis
121
130
  exporter = PDFExporter()
122
131
  filename = self._make_filename(start_date, end_date, project, 'pdf')
132
+ if report_type == 'executive':
133
+ filename = filename.replace('monthly-report_', 'executive-summary_', 1)
123
134
  output_path = output_dir / filename
124
135
  metrics['pdf_analysis'] = build_pdf_analysis(data)
125
136
  exporter.export(metrics, sections, report_meta, output_path)
@@ -176,6 +176,9 @@
176
176
  .stat-val { font-size: 18px; font-weight: 700; }
177
177
  .stat-lbl { font-size: 11px; color: var(--muted); text-transform: uppercase;
178
178
  letter-spacing: .04em; margin-top: 2px; }
179
+ .card-coverage { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border);
180
+ color: var(--muted); font-size: 12px; }
181
+ .card-coverage strong { color: var(--blue); font-size: 14px; }
179
182
 
180
183
  /* ── Custom tooltip ── */
181
184
  [data-tooltip] { position: relative; }
@@ -472,6 +475,7 @@
472
475
  '<div class="stat-lbl">Test Files</div>' +
473
476
  '</div>' +
474
477
  '</div>' +
478
+ '<div class="card-coverage" id="coverage-card-' + i + '">Automation coverage not supplied</div>' +
475
479
  '</a>';
476
480
  }).join('');
477
481
 
@@ -489,6 +493,24 @@
489
493
  drawSparkline(i, trend);
490
494
  });
491
495
  });
496
+
497
+ sorted.forEach(function(proj, i) {
498
+ fetch('coverage/' + encodeURIComponent(proj.name) + '/latest.json', { cache: 'no-store' })
499
+ .then(function(r) { if (!r.ok) throw new Error(r.status); return r.json(); })
500
+ .then(function(coverage) {
501
+ const total = coverage.total_items;
502
+ const automated = coverage.automated_items;
503
+ if (coverage.project_name !== proj.name || !Number.isInteger(total) || total < 1 ||
504
+ !Number.isInteger(automated) || automated < 0 || automated > total) return;
505
+ const el = document.getElementById('coverage-card-' + i);
506
+ if (!el) return;
507
+ el.innerHTML = 'Automation coverage <strong></strong> · <span></span> items';
508
+ el.querySelector('strong').textContent = (automated / total * 100).toFixed(1) + '%';
509
+ el.querySelector('span').textContent = automated.toLocaleString() + ' / ' + total.toLocaleString();
510
+ el.title = 'Project inventory as of ' + coverage.as_of;
511
+ })
512
+ .catch(function() { /* Coverage is optional for each project. */ });
513
+ });
492
514
  }
493
515
 
494
516
  fetch('data.json')
@@ -138,6 +138,20 @@
138
138
  .section-head h3 { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
139
139
  .section-explain { font-size: 13px; color: var(--muted); line-height: 1.5; }
140
140
  .section-body { padding: 20px 24px; }
141
+ .coverage-layout { display: flex; align-items: center; gap: 32px; flex-wrap: wrap; }
142
+ .coverage-ring { width: 148px; height: 148px; border-radius: 50%; flex: 0 0 148px;
143
+ display: grid; place-items: center; position: relative;
144
+ background: conic-gradient(var(--blue) 0deg var(--coverage-angle),
145
+ var(--border) var(--coverage-angle) 360deg); }
146
+ .coverage-ring::before { content: ''; position: absolute; inset: 18px;
147
+ border-radius: 50%; background: var(--surface); }
148
+ .coverage-ring-label { position: relative; z-index: 1; text-align: center;
149
+ font-size: 25px; font-weight: 800; line-height: 1.1; }
150
+ .coverage-ring-label small { display: block; font-size: 11px; font-weight: 500;
151
+ color: var(--muted); margin-top: 5px; }
152
+ .coverage-details { display: grid; gap: 7px; font-size: 15px; }
153
+ .coverage-details strong { font-size: 20px; color: var(--blue); }
154
+ .coverage-details .coverage-date { font-size: 12px; color: var(--muted); }
141
155
  .section-body-flush { }
142
156
 
143
157
  /* Collapsible sections with preview */
@@ -619,6 +633,13 @@
619
633
  }).join('');
620
634
 
621
635
  return hero +
636
+ '<div class="section">' +
637
+ '<div class="section-head">' +
638
+ '<h3>Automation Coverage</h3>' +
639
+ '<p class="section-explain">Automated items divided by all tracked items in the project inventory. Supplied by the project; separate from the test pass rate.</p>' +
640
+ '</div>' +
641
+ '<div class="section-body" id="coverageContent">Coverage data has not been published for this project.</div>' +
642
+ '</div>' +
622
643
  '<div class="section">' +
623
644
  '<div class="section-head">' +
624
645
  '<h3>Recent Test Runs</h3>' +
@@ -1364,6 +1385,33 @@
1364
1385
  '<div id="tab-analysis" class="tab-panel">' + renderAnalysis(analytics) + '</div>' +
1365
1386
  '<div id="tab-history" class="tab-panel">' + renderHistory(proj.suites || {}) + '</div>';
1366
1387
 
1388
+ fetch('coverage/' + encodeURIComponent(projectName) + '/latest.json', { cache: 'no-store' })
1389
+ .then(function(r) { if (!r.ok) throw new Error(r.status); return r.json(); })
1390
+ .then(function(coverage) {
1391
+ const total = coverage.total_items;
1392
+ const automated = coverage.automated_items;
1393
+ if (coverage.project_name !== projectName || !Number.isInteger(total) || total < 1 ||
1394
+ !Number.isInteger(automated) || automated < 0 || automated > total) return;
1395
+ const rate = automated / total * 100;
1396
+ const panel = document.getElementById('coverageContent');
1397
+ if (!panel) return;
1398
+ panel.innerHTML = '<div class="coverage-layout">' +
1399
+ '<div class="coverage-ring" id="coverageRing"><div class="coverage-ring-label" id="coverageRate"></div></div>' +
1400
+ '<div class="coverage-details">' +
1401
+ '<div><strong id="coverageAutomated"></strong> automated items</div>' +
1402
+ '<div><span id="coverageManual"></span> not automated items</div>' +
1403
+ '<div><span id="coverageTotal"></span> total tracked items</div>' +
1404
+ '<div class="coverage-date" id="coverageDate"></div>' +
1405
+ '</div></div>';
1406
+ document.getElementById('coverageRing').style.setProperty('--coverage-angle', (rate * 3.6) + 'deg');
1407
+ document.getElementById('coverageRate').innerHTML = rate.toFixed(1) + '%<small>automated</small>';
1408
+ document.getElementById('coverageAutomated').textContent = automated.toLocaleString();
1409
+ document.getElementById('coverageManual').textContent = (total - automated).toLocaleString();
1410
+ document.getElementById('coverageTotal').textContent = total.toLocaleString();
1411
+ document.getElementById('coverageDate').textContent = 'Project inventory as of ' + coverage.as_of;
1412
+ })
1413
+ .catch(function() { /* Coverage is optional; keep the unavailable message. */ });
1414
+
1367
1415
  // Trigger first tab animation
1368
1416
  requestAnimationFrame(function() {
1369
1417
  const panel = document.getElementById('tab-overview');
@@ -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.4.2',
12
+ version='4.4.4',
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.4.2
3
+ Version: 4.4.4
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
@@ -254,6 +254,7 @@ dashboard_max_runs_per_suite = 50 # Run history per suite (default: 50)
254
254
  | Command | Description |
255
255
  |---|---|
256
256
  | `test-report publish` | Push latest test run to the store |
257
+ | `test-report publish-coverage` | Publish project-owned automation inventory counts |
257
258
  | `test-report deploy` | Deploy static dashboard HTML to the store (run once) |
258
259
  | `test-report open` | Open local dashboard in browser |
259
260
  | `test-report stats` | Show stats from latest run (reads local SQLite) |
@@ -322,6 +323,8 @@ retention_days = 90 # Keep 90 days of artifacts and data
322
323
 
323
324
  Generate a report for one project from its published S3 or local run history. PDF is the default stakeholder report; PowerPoint and Excel are optional exports. The local UI offers rolling date presets, all published history, and custom dates. Reports are downloaded locally and do not change the publishing pipeline.
324
325
 
326
+ Projects can also publish QA-maintained automation inventory counts with `test-report publish-coverage --config reporting-jenkins.ini --file coverage.json`. The dashboard and monthly reports show the resulting automation coverage separately from test pass rates. See [MONTHLY_REPORTS.md](MONTHLY_REPORTS.md#project-supplied-automation-coverage) for the file format and publishing steps.
327
+
325
328
  For AWS SSO setup, commands, date selection, and metric definitions, see [MONTHLY_REPORTS.md](MONTHLY_REPORTS.md).
326
329
 
327
330
  ---
@@ -5,6 +5,7 @@ reporting/__init__.py
5
5
  reporting/classifier.py
6
6
  reporting/cli.py
7
7
  reporting/config.py
8
+ reporting/coverage.py
8
9
  reporting/monthly_report.py
9
10
  reporting/monthly_ui.py
10
11
  reporting/pdf_analysis.py
@@ -16,6 +16,7 @@ from reporting.monthly_report import MonthlyReportGenerator
16
16
  from reporting.monthly_ui import make_handler
17
17
  from reporting.run_source import PublishedRunSource
18
18
  from reporting.pdf_analysis import build_pdf_analysis
19
+ from reporting.coverage import CoverageStore, validate_coverage
19
20
 
20
21
 
21
22
  class PublishedMonthlyReportTests(unittest.TestCase):
@@ -66,6 +67,81 @@ class PublishedMonthlyReportTests(unittest.TestCase):
66
67
  self.assertTrue(metrics['summary']['detail_complete'])
67
68
  self.assertEqual(metrics['failure_types'][0]['count'], 1)
68
69
 
70
+ def test_coverage_snapshots_are_project_scoped_and_time_aware(self):
71
+ self.config.PROJECT_NAME = 'Project A'
72
+ store = CoverageStore(self.config)
73
+ source = self.config.STORE_PATH / 'coverage-input.json'
74
+ source.write_text(json.dumps({'as_of': '2026-10-01', 'total_items': 120,
75
+ 'automated_items': 48}), encoding='utf-8')
76
+ snapshot = store.publish(source)
77
+ self.assertEqual(snapshot['coverage_percent'], 40.0)
78
+ self.assertEqual(snapshot['not_automated_items'], 72)
79
+ self.assertIsNone(store.as_of('Project A', '2026-09-30'))
80
+ self.assertEqual(store.as_of('Project A', '2026-10-31')['automated_items'], 48)
81
+ source.write_text(json.dumps({'as_of': '2026-10-15', 'total_items': 120,
82
+ 'automated_items': 60}), encoding='utf-8')
83
+ store.publish(source)
84
+ self.assertEqual(store.as_of('Project A', '2026-10-10')['automated_items'], 48)
85
+ self.assertEqual(store.as_of('Project A', '2026-10-31')['automated_items'], 60)
86
+ source.write_text(json.dumps({'as_of': '2026-09-01', 'total_items': 120,
87
+ 'automated_items': 35}), encoding='utf-8')
88
+ store.publish(source)
89
+ latest = json.loads((self.config.STORE_PATH / 'coverage' / 'Project A' /
90
+ 'latest.json').read_text(encoding='utf-8'))
91
+ self.assertEqual(latest['as_of'], '2026-10-15')
92
+
93
+ def test_coverage_rejects_invalid_or_mismatched_counts(self):
94
+ with self.assertRaisesRegex(ValueError, 'total_items'):
95
+ validate_coverage({'as_of': '2026-10-01', 'total_items': 10,
96
+ 'automated_items': 11}, 'Project A')
97
+ with self.assertRaisesRegex(ValueError, 'total_items'):
98
+ validate_coverage({'as_of': '2026-10-01', 'total_items': True,
99
+ 'automated_items': 1}, 'Project A')
100
+ with self.assertRaisesRegex(ValueError, 'match reporting.ini'):
101
+ validate_coverage({'project_name': 'Project B', 'as_of': '2026-10-01',
102
+ 'total_items': 10, 'automated_items': 1}, 'Project A')
103
+
104
+ def test_s3_coverage_uses_separate_project_keys(self):
105
+ class MissingKey(Exception):
106
+ response = {'Error': {'Code': 'NoSuchKey'}}
107
+
108
+ class S3Client:
109
+ def __init__(self):
110
+ self.objects = {}
111
+
112
+ def put_object(self, **kwargs):
113
+ self.objects[kwargs['Key']] = kwargs['Body']
114
+
115
+ def get_object(self, **kwargs):
116
+ key = kwargs['Key']
117
+ if key not in self.objects:
118
+ raise MissingKey()
119
+ return {'Body': io.BytesIO(self.objects[key])}
120
+
121
+ def get_paginator(self, operation):
122
+ self.operation = operation
123
+ return self
124
+
125
+ def paginate(self, **kwargs):
126
+ return [{'Contents': [{'Key': key} for key in self.objects
127
+ if key.startswith(kwargs['Prefix'])]}]
128
+
129
+ config = SimpleNamespace(STORE_TYPE='s3', STORE_PATH=Path(self.tmp.name),
130
+ PROJECT_NAME='Project A', S3_PREFIX='prod',
131
+ S3_BUCKET='bucket', S3_REGION='us-east-1')
132
+ client = S3Client()
133
+ source = config.STORE_PATH / 'coverage-input.json'
134
+ source.write_text(json.dumps({'as_of': '2026-10-01', 'total_items': 20,
135
+ 'automated_items': 8}), encoding='utf-8')
136
+ store = CoverageStore(config, s3_client=client)
137
+ store.publish(source)
138
+ self.assertEqual(sorted(client.objects), [
139
+ 'prod/coverage/Project A/2026-10-01.json',
140
+ 'prod/coverage/Project A/latest.json',
141
+ ])
142
+ self.assertEqual(store.as_of('Project A', '2026-10-01')['coverage_percent'], 40.0)
143
+ self.assertIsNone(store.as_of('Project A', '2026-09-30'))
144
+
69
145
  def test_incomplete_detail_does_not_create_misleading_test_metrics(self):
70
146
  run_path = self.config.STORE_PATH / 'runs' / 'Project A' / 'current.json'
71
147
  run = json.loads(run_path.read_text(encoding='utf-8'))
@@ -183,6 +259,11 @@ class PublishedMonthlyReportTests(unittest.TestCase):
183
259
  @unittest.skipUnless(all(importlib.util.find_spec(x) for x in ('pptx', 'openpyxl', 'reportlab')),
184
260
  'Install test-reporting[reports] to test exports')
185
261
  def test_generate_all_formats_with_previous_period(self):
262
+ self.config.PROJECT_NAME = 'Project A'
263
+ coverage_file = self.config.STORE_PATH / 'coverage-input.json'
264
+ coverage_file.write_text(json.dumps({'as_of': '2026-10-01', 'total_items': 20,
265
+ 'automated_items': 8}), encoding='utf-8')
266
+ CoverageStore(self.config).publish(coverage_file)
186
267
  generator = MonthlyReportGenerator(self.config)
187
268
  files = generator.generate('2026-10-01', '2026-10-01', project='Project A',
188
269
  formats=['pdf', 'pptx', 'xlsx'],
@@ -194,11 +275,14 @@ class PublishedMonthlyReportTests(unittest.TestCase):
194
275
  workbook = load_workbook(next(p for p in files if p.suffix == '.xlsx'))
195
276
  self.assertNotIn('Recommendations', workbook.sheetnames)
196
277
  self.assertEqual(workbook['Summary']['A24'].value, 'KEY FINDINGS')
278
+ self.assertEqual(workbook['Summary']['B22'].value, '40.0%')
279
+ self.assertEqual(workbook['Automation Coverage']['B5'].value, 8)
197
280
  self.assertIn('100.0% pass rate', workbook['Summary']['A25'].value)
198
281
  self.assertEqual(workbook['Pass Rate Trend'].freeze_panes, 'B2')
199
282
  deck = Presentation(next(p for p in files if p.suffix == '.pptx'))
200
283
  self.assertNotIn('Recommendations',
201
284
  [slide.shapes.title.text for slide in deck.slides if slide.shapes.title])
285
+ self.assertEqual(deck.slides[2].shapes.title.text, 'Automation Coverage')
202
286
  summary_text = ' '.join(shape.text for shape in deck.slides[1].shapes if shape.has_text_frame)
203
287
  self.assertIn('KEY FINDINGS', summary_text)
204
288
  self.assertIn('100.0% pass rate', summary_text)
@@ -210,6 +294,36 @@ class PublishedMonthlyReportTests(unittest.TestCase):
210
294
  output_dir=self.config.STORE_PATH / 'exports')
211
295
  self.assertEqual([path.suffix for path in files], ['.pdf'])
212
296
 
297
+ @unittest.skipUnless(importlib.util.find_spec('reportlab'), 'Install test-reporting[reports]')
298
+ def test_executive_summary_is_short_pdf_with_period_measures(self):
299
+ self.config.PROJECT_NAME = 'Project A'
300
+ coverage_file = self.config.STORE_PATH / 'coverage-input.json'
301
+ coverage_file.write_text(json.dumps({'as_of': '2026-10-01', 'total_items': 20,
302
+ 'automated_items': 8}), encoding='utf-8')
303
+ CoverageStore(self.config).publish(coverage_file)
304
+ files = MonthlyReportGenerator(self.config).generate(
305
+ '2026-10-01', '2026-10-01', project='Project A',
306
+ report_type='executive', output_dir=self.config.STORE_PATH / 'exports')
307
+ self.assertEqual(len(files), 1)
308
+ self.assertIn('executive-summary_', files[0].name)
309
+ self.assertGreater(files[0].stat().st_size, 1000)
310
+ if importlib.util.find_spec('pypdf'):
311
+ from pypdf import PdfReader
312
+ pages = PdfReader(str(files[0])).pages
313
+ self.assertLessEqual(len(pages), 2)
314
+ text = ' '.join(page.extract_text() for page in pages)
315
+ self.assertIn('Executive Summary', text)
316
+ self.assertIn('Previous period', text)
317
+ self.assertIn('Automation coverage', text)
318
+ self.assertIn('40.0%', text)
319
+ self.assertNotIn('Test files and test cases', text)
320
+
321
+ def test_executive_summary_rejects_other_formats(self):
322
+ with self.assertRaisesRegex(ValueError, 'PDF only'):
323
+ MonthlyReportGenerator(self.config).generate(
324
+ '2026-10-01', '2026-10-01', project='Project A',
325
+ report_type='executive', formats=['pdf', 'xlsx'])
326
+
213
327
 
214
328
  if __name__ == '__main__':
215
329
  unittest.main()
File without changes
File without changes