From 026862e4b0faac3742474f30bbadc73bb0392144 Mon Sep 17 00:00:00 2001 From: Shoptimizer Team Date: Wed, 14 Apr 2021 16:44:01 +0900 Subject: [PATCH] Add unit test for promo regex pattern detection. PiperOrigin-RevId: 368376764 --- .../util/promo_text_remover_test.py | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/shoptimizer_api/util/promo_text_remover_test.py b/shoptimizer_api/util/promo_text_remover_test.py index 697a733..7f43ce1 100644 --- a/shoptimizer_api/util/promo_text_remover_test.py +++ b/shoptimizer_api/util/promo_text_remover_test.py @@ -123,12 +123,26 @@ def test_text_remover_cleans_up_field_value(self): self.assertEqual('dummy title', product.get('title')) - @parameterized.named_parameters([{ - 'testcase_name': - 'one_promo_text_at_end_list_should_be_removed', - 'list_with_promo': ['カイナ', '高い', '悪い', 'ポイント消化'], - 'expected_result': {'カイナ', '高い', '悪い'} - }]) + @parameterized.named_parameters([ + { + 'testcase_name': + 'one_promo_text_at_end_list_exact_match_should_be_removed', + 'list_with_promo': [ + 'カイナ', '高い', '悪い', 'ポイント消化' + ], + 'expected_result': {'カイナ', '高い', '悪い'} + }, + { + 'testcase_name': 'promo_text_regex_pattern_pointo_is_removed', + 'list_with_promo': [ + 'カイナ', + '高い', + '悪い', + '【ポイント】' # will be detected by our regex and removed + ], + 'expected_result': {'カイナ', '高い', '悪い'} + } + ]) def test_remove_keywords_with_promo(self, list_with_promo, expected_result): result = self.text_remover.remove_keywords_with_promo(list_with_promo) self.assertEqual(result, expected_result)