This commit is contained in:
2026-11-03 08:44:11 +01:00
parent cbf5f20c75
commit 0a9da4f9c5
13 changed files with 422 additions and 5 deletions
+28
View File
@@ -279,6 +279,34 @@ class MainAppTest(unittest.TestCase):
self.assertEqual(Notification.query.filter_by(id=first_id).count(), 0)
self.assertEqual(Notification.query.filter_by(id=second_id).count(), 1)
def test_calendar_requires_login(self):
response = self.client.get("/calendar")
self.assertEqual(response.status_code, 302)
self.assertIn("/login", response.headers["Location"])
def test_calendar_month_and_week_views_render(self):
self.login()
month_response = self.client.get("/calendar?view=month")
self.assertEqual(month_response.status_code, 200)
self.assertIn("Calendar", month_response.get_data(as_text=True))
week_response = self.client.get("/calendar?view=week")
self.assertEqual(week_response.status_code, 200)
self.assertIn("Calendar", week_response.get_data(as_text=True))
def test_calendar_readouts_range_endpoint(self):
self.login()
sensor_id = self.create_sensor_and_readout("calendar-test")
response = self.client.get(
f"/api/sensors/{sensor_id}/readouts/range"
"?from=2000-01-01T00:00:00&to=2100-01-01T00:00:00"
)
self.assertEqual(response.status_code, 200)
data = response.get_json()
self.assertEqual(len(data), 1)
self.assertEqual(data[0]["sensor_id"], sensor_id)
def test_notes_require_login(self):
response = self.client.get("/notes")
self.assertEqual(response.status_code, 302)