Skip to content

Commit

Permalink
Add unit test for promo regex pattern detection.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 368376764
  • Loading branch information
Shoptimizer Team authored and starmandeluxe committed Apr 21, 2021
1 parent 239e59d commit 026862e
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions shoptimizer_api/util/promo_text_remover_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 026862e

Please sign in to comment.