Exemple #1
0
    def test_extract_no_match(self):
        text_preprocessing_result = Mock()
        text_preprocessing_result.original_text = "text"

        filler = RegexpFieldFiller(self.items)
        result = filler.extract(text_preprocessing_result, self.user)

        self.assertIsNone(result)
Exemple #2
0
    def test_no_exp(self):
        field_value = "1-RSAR09A"
        text_preprocessing_result = Mock()
        text_preprocessing_result.original_text = field_value

        filler = RegexpFieldFiller(self.items)
        filler.regexp = None
        self.assertIsNone(filler.extract(text_preprocessing_result, self.user))
Exemple #3
0
    def test_extract(self):
        field_value = "1-RSAR09A"
        text_preprocessing_result = Mock()
        text_preprocessing_result.original_text = field_value

        filler = RegexpFieldFiller(self.items)
        result = filler.extract(text_preprocessing_result, self.user)

        self.assertEqual(field_value, result)
Exemple #4
0
    def test_extract_mult_match_default_delimiter(self):
        field_value = "1-RSAR09A пустой тест 1-RSAR02A"
        res = ",".join(['1-RSAR09A', '1-RSAR02A'])
        text_preprocessing_result = Mock()
        text_preprocessing_result.original_text = field_value

        filler = RegexpFieldFiller(self.items)
        result = filler.extract(text_preprocessing_result, self.user)

        self.assertEqual(res, result)
    def test_extract_mult_match_custom_delimiter(self):
        field_value = "1-RSAR09A пустой тест 1-RSAR02B"
        self.items["delimiter"] = ";"
        res = self.items["delimiter"].join(['1-RSAR09A', '1-RSAR02B'])
        text_preprocessing_result = PicklableMock()
        text_preprocessing_result.original_text = field_value

        filler = RegexpFieldFiller(self.items)
        result = filler.extract(text_preprocessing_result, self.user)

        self.assertEqual(res, result)