feat(map): add cached public station navigation
This commit is contained in:
@@ -47,5 +47,17 @@ class DashboardTest(unittest.TestCase):
|
||||
index_template = (Path(__file__).parents[1] / "index.html").read_text(encoding="utf-8")
|
||||
self.assertEqual(index_template.count("__ASSET_VERSION__"), 2)
|
||||
|
||||
def test_default_cache_window_is_two_minutes(self):
|
||||
self.assertEqual(server.DASHBOARD_CACHE_SECONDS, 120)
|
||||
self.assertEqual(server.STATION_CACHE_SECONDS, 120)
|
||||
|
||||
def test_cache_reuses_dashboard_snapshot_within_window(self):
|
||||
calls = []
|
||||
with patch.object(server, "_cache", {}):
|
||||
first = server._cached("dashboard", 120, lambda: calls.append("load") or {"version": 1})
|
||||
second = server._cached("dashboard", 120, lambda: calls.append("load") or {"version": 2})
|
||||
self.assertEqual(calls, ["load"])
|
||||
self.assertEqual(first, second)
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user