fix(api): validate nested report fields

This commit is contained in:
nyan404 committed 2026-08-25 04:06:25 +03:00
1 parent 92171731ae
commit 0aec421ad2
6 files changed
+48 -6

No files matched your search

+18
View File
@@ -117,6 +117,24 @@ class ApiTests(unittest.TestCase):
with self.assertRaisesRegex(ApiError, "не более 50 котят"):
calculate_payload(payload)
def test_api_rejects_boolean_and_malformed_nested_report_values(self):
coaching = {
"mode": "coaching", "date": "15.08", "skill": "ЛУ", "start": "11:00", "end": "11:20",
"escort_name": "Белка", "escort_id": 1, "kitten_name": "Первый", "kitten_id": 2,
"extra_kittens": [{"name": "Второй", "id": True}],
}
with self.assertRaisesRegex(ApiError, "ID дополнительного котёнка"):
calculate_payload(coaching)
inspection = {
"mode": "inspection", "character_name": "Белка", "character_id": 1,
"place": "дупло", "inspections": 1, "resources": [["паутина", True]],
}
with self.assertRaisesRegex(ApiError, "Количество ресурса"):
calculate_payload(inspection)
inspection["resources"] = "паутина=1"
with self.assertRaisesRegex(ApiError, "resources должно быть списком"):
calculate_payload(inspection)
if __name__ == "__main__":
unittest.main()