fix(identity): validate persistent character pairs
This commit is contained in:
1 parent
0aec421ad2
commit
6af34d4706
8 files changed
+44
-1
No files matched your search
@@ -93,6 +93,11 @@ class ApiTests(unittest.TestCase):
|
||||
self.assertEqual(response["status"], "provided")
|
||||
self.assertIsNone(directory.resolve(character_id=1617140))
|
||||
|
||||
def test_identity_lookup_rejects_boolean_and_non_positive_ids(self):
|
||||
for character_id in (True, 0, -1):
|
||||
with self.subTest(character_id=character_id), self.assertRaises(ApiError):
|
||||
resolve_identity_payload({"character_id": character_id})
|
||||
|
||||
def test_calculation_store_persists_full_record(self):
|
||||
with TemporaryDirectory() as directory:
|
||||
path = f"{directory}/history.sqlite3"
|
||||
|
||||
@@ -104,6 +104,14 @@ class ApplicationTests(unittest.TestCase):
|
||||
self.assertIn("отправлена", dialog.handle(55, 55, "готово").lower())
|
||||
self.assertEqual(store.list()[0]["application"]["type"], "kitten")
|
||||
|
||||
def test_identity_directory_rejects_invalid_persistent_pairs(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
identities = IdentityDirectory(db_path=Path(directory) / "identities.sqlite3")
|
||||
with self.assertRaises(ValueError):
|
||||
identities.remember(name="", character_id=1)
|
||||
with self.assertRaises(ValueError):
|
||||
identities.remember(name="Белка", character_id=0)
|
||||
|
||||
def test_vk_application_uses_keyboard_for_menu_and_branches(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
store = ApplicationStore(sqlite_path=Path(directory) / "applications.sqlite3")
|
||||
|
||||
@@ -104,6 +104,15 @@ class VkConversationTests(unittest.TestCase):
|
||||
dialog.handle(1, "/лу")
|
||||
self.assertIn("отмен", dialog.handle(1, "/отмена").lower())
|
||||
|
||||
def test_person_input_rejects_a_non_positive_id(self):
|
||||
dialog = BelkiDialog()
|
||||
dialog.handle(1, "/лу")
|
||||
dialog.handle(1, "15.08")
|
||||
dialog.handle(1, "ЛУ")
|
||||
dialog.handle(1, "11:00")
|
||||
dialog.handle(1, "11:20")
|
||||
self.assertIn("положительным", dialog.handle(1, "Белка [0]").lower())
|
||||
|
||||
def test_bulk_inspector_returns_fields_and_missing_questions(self):
|
||||
inspected = inspect_bulk_text("/лу 15.08 11:00 11:20 | Белка [1] | Котёнок [2]")
|
||||
self.assertEqual(inspected["status"], "needs_clarification")
|
||||
|
||||
Reference in new issue
Block a user