feat: add earned points calculator

This commit is contained in:
nyan404 committed 2026-08-25 13:32:33 +03:00
1 parent 8e4f461e8b
commit 9e3b50c967
7 files changed
+160 -5

No files matched your search

+14
View File
@@ -44,6 +44,20 @@ class ApiTests(unittest.TestCase):
self.assertEqual(response["result"]["total_hours"], 2)
self.assertIn("Осталось добрать: 24", response["message"])
def test_points_calculator_returns_separate_coach_and_kittens(self):
response = calculate_payload({
"mode": "points", "activity": "coaching", "skill": "ЛУ", "start": "11:00", "end": "11:20",
"kitten_statuses": ["самостоятельно", "несамостоятельно"],
})
self.assertEqual(response["result"], {"minutes": 20, "curator_points": 8, "kitten_points": [4, 4]})
def test_points_calculator_supports_training_and_inspection(self):
self.assertEqual(calculate_payload({"mode": "points", "activity": "training"})["result"]["kitten_points"], 25)
self.assertEqual(calculate_payload({
"mode": "points", "activity": "inspection", "place": "дупло", "inspections": 2,
"resources": [["паук", 1]],
})["result"]["points"], 5)
def test_goal_calculator_rejects_non_finite_json_number(self):
with self.assertRaisesRegex(ApiError, "конечным числом"):
calculate_payload({
+12
View File
@@ -27,6 +27,18 @@ class VkConversationTests(unittest.TestCase):
dialog.handle(110, "10")
self.assertIn("от 1 до 1440", dialog.handle(110, "1441"))
def test_calculator_replaces_goal_with_points_dialog(self):
dialog = BelkiDialog()
self.assertIn("прокачку", dialog.handle(111, "/калькулятор").lower())
self.assertIn("навык", dialog.handle(111, "прокачка").lower())
dialog.handle(111, "ЛУ")
dialog.handle(111, "11:00")
dialog.handle(111, "11:20")
dialog.handle(111, "2")
response = dialog.handle(111, "сам, несам")
self.assertIn("Куратор: 8", response)
self.assertIn("Бельчонок 2: 4", response)
def test_step_by_step_coaching_dialog(self):
dialog = BelkiDialog()
self.assertIn("дат", dialog.handle(77, "/лу").lower())