add pictures to statcounter

This commit is contained in:
2026-10-18 11:21:25 +02:00
parent ca5af75bbd
commit 3ebfeca7cc
5 changed files with 1225 additions and 32 deletions
+53
View File
@@ -129,6 +129,59 @@ class StatsPageTest(unittest.TestCase):
self.assertIn("Estimated · exact every 2 h", html)
self.assertIn("imagesExact", html)
def test_page_contains_6h_range_and_card(self):
client = stats_app.app.test_client()
response = client.get("/")
self.assertEqual(response.status_code, 200)
html = response.get_data(as_text=True)
self.assertIn('data-range="6h"', html)
self.assertIn('id="stat-delta-6h"', html)
self.assertIn('id="stat-delta-6h-hint"', html)
self.assertIn("'6h': 6 * 3600000", html)
self.assertIn("closestBefore(all, last.x - 6 * 3600000", html)
def test_page_contains_all_image_graphs(self):
client = stats_app.app.test_client()
response = client.get("/")
self.assertEqual(response.status_code, 200)
html = response.get_data(as_text=True)
self.assertIn("Images – all graphs", html)
for canvas in (
"imagesMainChart",
"imagesDeltaChart",
"imagesCumChart",
"imagesHourlyChart",
"imagesHodChart",
):
self.assertIn('id="' + canvas + '"', html)
self.assertIn('id="records-images"', html)
self.assertIn('id="heatmap-images"', html)
self.assertIn('id="images-empty"', html)
# the image series skips entries without an image count (old data)
# and only plots exact measurements - no estimates between the 2 h counts
self.assertIn("function toImagePoints(points)", html)
self.assertIn("p.images !== null && p.images !== undefined", html)
self.assertIn(".filter(function (p) { return p.imagesExact; })", html)
self.assertIn("only exact measurements are plotted (no estimates)", html)
self.assertIn("Only exact measurements (counted every 2 h) are plotted", html)
self.assertIn("Only estimated image counts so far", html)
self.assertIn("No exact image counts in the selected range", html)
# existing page chart ids must stay lowercase (mainChart, not MainChart)
self.assertIn("function chartId(prefix, suffix)", html)
self.assertIn("chartId(prefix, 'MainChart')", html)
# both series use the same time window (anchored to the latest page sample)
self.assertIn("filterRange(imageAll, last.x)", html)
# both metrics go through the same renderers, with the right units
self.assertIn("unit: 'Images'", html)
self.assertIn("unit: 'Pages'", html)
self.assertIn("renderRecords(deltas, 'records', 'Pages')", html)
self.assertIn("renderRecords(imageDeltas, 'records-images', 'Images')", html)
self.assertIn("renderHeatmap(all, 'heatmap', 'Pages')", html)
self.assertIn("renderHeatmap(imageAll, 'heatmap-images', 'Images')", html)
if __name__ == "__main__":
unittest.main(verbosity=2)