22 lines
704 B
Python
22 lines
704 B
Python
|
|
"""Timeline bucket_hours + static Cache-Control."""
|
||
|
|
|
||
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
from pathlib import Path
|
||
|
|
|
||
|
|
ROOT = Path(__file__).resolve().parent.parent
|
||
|
|
|
||
|
|
|
||
|
|
def test_timeline_uses_bucket_hours():
|
||
|
|
src = (ROOT / "app/main.py").read_text()
|
||
|
|
fn = src.split("async def get_timeline")[1].split("async def sentiment_by_source")[0]
|
||
|
|
assert "bucket_hours" in fn
|
||
|
|
assert "date_trunc('hour'" not in fn or "bucket" in fn.lower()
|
||
|
|
# Must not ignore the query param.
|
||
|
|
assert ":bucket" in fn or "bucket_hours" in fn.split("text(")[1][:800]
|
||
|
|
|
||
|
|
|
||
|
|
def test_static_vendor_cache_control():
|
||
|
|
src = (ROOT / "app/main.py").read_text()
|
||
|
|
assert "max-age=31536000" in src or "immutable" in src.lower()
|