fix(goal): bound public calculator inputs

This commit is contained in:
nyan404 committed 2026-08-25 03:34:58 +03:00
1 parent 041d717439
commit 5d6e5987d1
8 files changed
+58 -8

No files matched your search

+7
View File
@@ -44,6 +44,13 @@ class ApiTests(unittest.TestCase):
self.assertEqual(response["result"]["total_hours"], 2)
self.assertIn("Осталось добрать: 24", response["message"])
def test_goal_calculator_rejects_non_finite_json_number(self):
with self.assertRaisesRegex(ApiError, "конечным числом"):
calculate_payload({
"mode": "goal", "current_points": "NaN", "target_points": 34,
"minutes_per_session": 20, "kitten_count": 1,
})
def test_calculate_and_store_uses_calculation_store(self):
with TemporaryDirectory() as directory:
with patch.dict("os.environ", {"BELKI_DATABASE_URL": "", "BELKI_HISTORY_DB": f"{directory}/history.sqlite3"}, clear=False):