def test_any_substring_in_lowered_text_requirement_false(self): """Тест кейз проверяет что условие возвращает False, т.к НЕ нашлась ни одна подстрока из списка substrings, которая бы встречалась в оригинальном тексте в нижнем регистре. """ req = AnySubstringInLoweredTextRequirement( {"substrings": ["искомая подстрока", "другая подстрока"]}) text_preprocessing_result = PicklableMock() text_preprocessing_result.raw = {"original_text": "КАКОЙ-ТО ТЕКСТ"} result = req.check(text_preprocessing_result, PicklableMock()) self.assertFalse(result)
def test_add_1(self): user = PicklableMock() items = None description = PicklableMock() description.max_message_count = 3 description.lifetime = 10 preprocessing_messages = PreprocessingScenariosMessages(items, description, user) text_preprocessing_result = PicklableMock() text_preprocessing_result.raw = {"test": 123} preprocessing_messages.add(text_preprocessing_result) self.assertEqual([item for item in preprocessing_messages.processed_items], [{"test": 123}])
def test_add_3(self): user = PicklableMock() items = [{"ts": 35343820800, "message": {"test": 567}, "direction": "incoming"}] description = PicklableMock() description.max_message_count = 1 description.lifetime = 10 preprocessing_messages = PreprocessingScenariosMessages(items, description, user) text_preprocessing_result = PicklableMock() text_preprocessing_result.raw = {"test": 123} preprocessing_messages.add(text_preprocessing_result) self.assertListEqual([item for item in preprocessing_messages.processed_items], [{"test": 123}])
def test_any_substring_in_lowered_text_requirement_true(self): """Тест кейз проверяет что условие возвращает True, т.к нашлась подстрока из списка substrings, которая встречается в оригинальном тексте в нижнем регистре. """ req = AnySubstringInLoweredTextRequirement( {"substrings": ["искомая подстрока", "другое знанчение"]}) text_preprocessing_result = PicklableMock() text_preprocessing_result.raw = { "original_text": "КАКОЙ-ТО ТЕКСТ С ИСКОМАЯ ПОДСТРОКА" } result = req.check(text_preprocessing_result, PicklableMock()) self.assertTrue(result)
def test_normalized_text_in_set_requirement_false(self, mock_get_app_config): """Тест кейз проверяет что условие возвращает False, т.к в нормализованном представлении запрос НЕ совпадает ни с одной из нормализованных строк из input_words. """ patch_get_app_config(mock_get_app_config) req = NormalizedTextInSetRequirement( {"input_words": ["погода", "время"]}) text_preprocessing_result = PicklableMock() text_preprocessing_result.raw = {"normalized_text": "хотеть узнать ."} self.assertFalse(req.check(text_preprocessing_result, PicklableMock()))
def test_intersection_with_tokens_requirement_true(self, mock_get_app_config): """Тест кейз проверяет что условие возвращает True, т.к хотя бы одно слово из нормализованного вида запроса входит в список слов input_words. """ patch_get_app_config(mock_get_app_config) req = IntersectionWithTokensSetRequirement( {"input_words": ["погода", "время"]}) text_preprocessing_result = PicklableMock() text_preprocessing_result.raw = { "tokenized_elements_list_pymorphy": [{ "text": "прогноз", "grammem_info": { "animacy": "inan", "case": "acc", "gender": "masc", "number": "sing", "raw_gram_info": "animacy=inan|case=acc|gender=masc|number=sing", "part_of_speech": "NOUN" }, "lemma": "прогноз" }, { "text": "погоды", "grammem_info": { "animacy": "inan", "case": "gen", "gender": "fem", "number": "sing", "raw_gram_info": "animacy=inan|case=gen|gender=fem|number=sing", "part_of_speech": "NOUN" }, "lemma": "погода" }] } self.assertTrue(req.check(text_preprocessing_result, PicklableMock()))