feat: implement StaySense MVP backend, frontend, imports, and deployment docs
This commit is contained in:
commit
902988276c
24 changed files with 2536 additions and 0 deletions
21
backend/tests/test_open_data_connector.py
Normal file
21
backend/tests/test_open_data_connector.py
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from open_data_connector import import_from_config
|
||||
|
||||
|
||||
class OpenDataConnectorTests(unittest.TestCase):
|
||||
def test_import_from_config_has_stats(self) -> None:
|
||||
cfg = Path(__file__).resolve().parents[2] / "docs" / "open_data_sources.json"
|
||||
result = import_from_config(cfg, prune_legacy=True)
|
||||
self.assertIn("imported", result)
|
||||
self.assertIn("pruned", result)
|
||||
self.assertGreaterEqual(len(result["imported"]), 1)
|
||||
|
||||
imported = result["imported"][0]
|
||||
self.assertIn("stats", imported)
|
||||
self.assertIn("accepted", imported["stats"])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
25
backend/tests/test_score_engine.py
Normal file
25
backend/tests/test_score_engine.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import datetime as dt
|
||||
import unittest
|
||||
|
||||
from score_engine import ampel, clamp_score, night_window_for
|
||||
|
||||
|
||||
class ScoreEngineTests(unittest.TestCase):
|
||||
def test_ampel_thresholds(self) -> None:
|
||||
self.assertEqual(ampel(70), "green")
|
||||
self.assertEqual(ampel(45), "yellow")
|
||||
self.assertEqual(ampel(10), "red")
|
||||
|
||||
def test_clamp_score(self) -> None:
|
||||
self.assertEqual(clamp_score(-20), 0)
|
||||
self.assertEqual(clamp_score(120), 100)
|
||||
|
||||
def test_night_window(self) -> None:
|
||||
ref = dt.datetime(2026, 2, 15, 23, 30, tzinfo=dt.timezone.utc)
|
||||
start, end = night_window_for(ref)
|
||||
self.assertEqual(start.hour, 22)
|
||||
self.assertEqual(end.hour, 6)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue