chat: added validation during initialization
This commit is contained in:
@@ -203,6 +203,17 @@ class TestChatDB(unittest.TestCase):
|
||||
self.cache_path.cleanup()
|
||||
pass
|
||||
|
||||
def test_validate(self) -> None:
|
||||
duplicate_message = Message(Question('Question 4'),
|
||||
Answer('Answer 4'),
|
||||
{Tag('tag4')},
|
||||
file_path=pathlib.Path('0004.txt'))
|
||||
duplicate_message.to_file(pathlib.Path(self.db_path.name, '0004.txt'))
|
||||
with self.assertRaises(ChatError) as cm:
|
||||
ChatDB.from_dir(pathlib.Path(self.cache_path.name),
|
||||
pathlib.Path(self.db_path.name))
|
||||
self.assertEqual(str(cm.exception), "Validation failed")
|
||||
|
||||
def test_from_dir(self) -> None:
|
||||
chat_db = ChatDB.from_dir(pathlib.Path(self.cache_path.name),
|
||||
pathlib.Path(self.db_path.name))
|
||||
|
||||
Reference in New Issue
Block a user