test-reporting 4.2.0__tar.gz → 4.2.1__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.
- {test_reporting-4.2.0 → test_reporting-4.2.1}/PKG-INFO +1 -1
- {test_reporting-4.2.0 → test_reporting-4.2.1}/reporting/monthly_report.py +15 -9
- {test_reporting-4.2.0 → test_reporting-4.2.1}/reporting/monthly_ui.py +1 -1
- {test_reporting-4.2.0 → test_reporting-4.2.1}/reporting/run_source.py +25 -2
- {test_reporting-4.2.0 → test_reporting-4.2.1}/setup.py +1 -1
- {test_reporting-4.2.0 → test_reporting-4.2.1}/test_reporting.egg-info/PKG-INFO +1 -1
- {test_reporting-4.2.0 → test_reporting-4.2.1}/tests/test_published_monthly_report.py +12 -5
- {test_reporting-4.2.0 → test_reporting-4.2.1}/LICENSE +0 -0
- {test_reporting-4.2.0 → test_reporting-4.2.1}/README.md +0 -0
- {test_reporting-4.2.0 → test_reporting-4.2.1}/reporting/__init__.py +0 -0
- {test_reporting-4.2.0 → test_reporting-4.2.1}/reporting/classifier.py +0 -0
- {test_reporting-4.2.0 → test_reporting-4.2.1}/reporting/cli.py +0 -0
- {test_reporting-4.2.0 → test_reporting-4.2.1}/reporting/config.py +0 -0
- {test_reporting-4.2.0 → test_reporting-4.2.1}/reporting/exporters/__init__.py +0 -0
- {test_reporting-4.2.0 → test_reporting-4.2.1}/reporting/exporters/pdf_exporter.py +0 -0
- {test_reporting-4.2.0 → test_reporting-4.2.1}/reporting/exporters/pptx_exporter.py +0 -0
- {test_reporting-4.2.0 → test_reporting-4.2.1}/reporting/exporters/xlsx_exporter.py +0 -0
- {test_reporting-4.2.0 → test_reporting-4.2.1}/reporting/plugin.py +0 -0
- {test_reporting-4.2.0 → test_reporting-4.2.1}/reporting/publisher.py +0 -0
- {test_reporting-4.2.0 → test_reporting-4.2.1}/reporting/storage.py +0 -0
- {test_reporting-4.2.0 → test_reporting-4.2.1}/reporting/templates/index.html +0 -0
- {test_reporting-4.2.0 → test_reporting-4.2.1}/reporting/templates/project.html +0 -0
- {test_reporting-4.2.0 → test_reporting-4.2.1}/reporting/templates/run.html +0 -0
- {test_reporting-4.2.0 → test_reporting-4.2.1}/setup.cfg +0 -0
- {test_reporting-4.2.0 → test_reporting-4.2.1}/test_reporting.egg-info/SOURCES.txt +0 -0
- {test_reporting-4.2.0 → test_reporting-4.2.1}/test_reporting.egg-info/dependency_links.txt +0 -0
- {test_reporting-4.2.0 → test_reporting-4.2.1}/test_reporting.egg-info/entry_points.txt +0 -0
- {test_reporting-4.2.0 → test_reporting-4.2.1}/test_reporting.egg-info/requires.txt +0 -0
- {test_reporting-4.2.0 → test_reporting-4.2.1}/test_reporting.egg-info/top_level.txt +0 -0
|
@@ -68,19 +68,25 @@ class MonthlyReportGenerator:
|
|
|
68
68
|
if project:
|
|
69
69
|
print(f"[Monthly Report] Project filter: {project}")
|
|
70
70
|
|
|
71
|
-
#
|
|
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)
|
|
71
|
+
# Read the current and comparison periods in one store pass.
|
|
76
72
|
period_days = (end - start).days + 1
|
|
77
73
|
previous_end = start - timedelta(days=1)
|
|
78
74
|
previous_start = previous_end - timedelta(days=period_days - 1)
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
75
|
+
combined = self.collect_data(previous_start.isoformat(), end_date, project)
|
|
76
|
+
current_ids = {r['id'] for r in combined['runs'] if r.get('timestamp', '')[:10] >= start_date}
|
|
77
|
+
previous_ids = {r['id'] for r in combined['runs'] if r.get('timestamp', '')[:10] < start_date}
|
|
78
|
+
data = {
|
|
79
|
+
'runs': [r for r in combined['runs'] if r['id'] in current_ids],
|
|
80
|
+
'results': [r for r in combined['results'] if r['run_id'] in current_ids],
|
|
81
|
+
}
|
|
82
|
+
previous_runs = [r for r in combined['runs'] if r['id'] in previous_ids]
|
|
83
|
+
if not data['runs']:
|
|
84
|
+
raise ValueError(f'No runs found for {project} from {start_date} to {end_date}')
|
|
85
|
+
metrics = self.calculate_metrics(data, top_n)
|
|
86
|
+
previous_total = sum(r.get('total_tests', 0) for r in previous_runs)
|
|
87
|
+
previous_passed = sum(r.get('passed', 0) for r in previous_runs)
|
|
82
88
|
summary = metrics['summary']
|
|
83
|
-
summary['previous_runs'] = len(
|
|
89
|
+
summary['previous_runs'] = len(previous_runs)
|
|
84
90
|
summary['previous_pass_rate'] = round(previous_passed / previous_total * 100, 1) if previous_total else None
|
|
85
91
|
summary['pass_rate_change'] = (round(summary['pass_rate'] - summary['previous_pass_rate'], 1)
|
|
86
92
|
if summary['previous_pass_rate'] is not None else None)
|
|
@@ -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
|
|
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
|
|
|
@@ -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
|
-
|
|
61
|
-
|
|
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.
|
|
12
|
+
version='4.2.1',
|
|
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",
|
|
@@ -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': [
|
|
86
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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))
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|