Ejemplo n.º 1
0
 def test_no_banned_words(self):
     text = [
         "alpha", "beta", "gamma", "delta", "epsilon", "zeta", "eta",
         "theta", "iota", "kappa", "lambda"
     ]
     banned = ["uno", "dos", "tres", "cuatro", "cinco", "seis"]
     assert list(redact_words(text, banned)) == text
Ejemplo n.º 2
0
    def test_upper_case(self):
        text_array = 'A a a jump over the dog'.split()
        banned_word = ['a']

        filter_array = redact_words(text_array, banned_word)
        assert filter_array.count('a') == 0
        assert filter_array.count('A') == 0
        assert len(filter_array) == 4
Ejemplo n.º 3
0
    def test_positive(self):
        text_array = 'A brown fox jump over the dog'.split()
        banned_word = ['brown', 'over']

        filter_array = redact_words(text_array, banned_word)

        assert 'brown' not in filter_array
        assert 'over' not in filter_array
        assert len(filter_array) == 5
Ejemplo n.º 4
0
 def test_redaction(self):
     text = [
         "alpha", "beta", "gamma", "delta", "epsilon", "zeta", "eta",
         "theta", "iota", "kappa", "lambda"
     ]
     banned = ["kappa", "gamma", "eta"]
     expected_result = [
         "alpha", "beta", "delta", "epsilon", "zeta", "theta", "iota",
         "lambda"
     ]
     assert list(redact_words(text, banned)) == expected_result
 def test_letters(self):
   list_1 = ['a','a','b','c']
   list_2 = ['c','d','e']
   expected_list = ['a', 'a', 'b']
   assert redact_words(list_1,list_2) == expected_list
 def test_more_words(self):
   list_5 = ['please','shut','up']
   list_6 = ['shut']
   expected_list = ['please', 'up']
   assert redact_words(list_5, list_6) == expected_list
 def test_words(self):
   list_3 = ['hello', 'my', 'name']
   list_4 = ['name', 'mi', 'helloo']
   expected_list = ['name']
   assert redact_words(list_3, list_4) == expected_list
 def test_basic(self):
     sentance = ['hello', 'world', 'goodbye', 'planet']
     redacted = ['goodbye', 'yes']
     modified = ['hello', 'world', 'planet']
     prog_modified = redact_words(sentance, redacted)
     assert prog_modified == modified
 def no_redacted(self):
     sentance = ['this', 'wont', 'change']
     redacted = []
     prog_modified = redact_words(sentance, redacted)
     assert prog_modified == []
Ejemplo n.º 10
0
 def test_all_banned_words(self):
     text = [
         "alpha", "beta", "gamma", "delta", "epsilon", "zeta", "eta",
         "theta", "iota", "kappa", "lambda"
     ]
     assert list(redact_words(text, text)) == []
Ejemplo n.º 11
0
 def test_with_no_matching_words(self):
     original = [1, 2, 3, 4, 5, 6, 7, 8]
     banned = [11, 12, 13, 14]
     redacted_words = redact_words(original, banned)
     self.assertCountEqual(redacted_words, original)
Ejemplo n.º 12
0
 def test_with_no_words(self):
     original = []
     banned = [1, 2, 3, 4, 5]
     assert redact_words(original, banned) == []
Ejemplo n.º 13
0
 def test_with_extra_banned_words(self):
     original = [1, 2, 3, 4, 5, 6, 7, 8]
     banned = [1, 3, 5, 7, 9, 11, 13]
     redacted_words = redact_words(original, banned)
     self.assertCountEqual(redacted_words, [2, 4, 6, 8])
Ejemplo n.º 14
0
 def test_with_strings(self):
     original = 'hello my name is Jake'.split(' ')
     banned = 'hello Jake'.split(' ')
     redacted_words = redact_words(original, banned)
     self.assertCountEqual(redacted_words, 'my name is'.split(' '))
Ejemplo n.º 15
0
 def test_with_integers(self):
     original = [1, 2, 3, 4, 5, 6, 7, 8, 9]
     banned = [1, 3, 5, 7, 9]
     redacted_words = (redact_words(original, banned))
     self.assertCountEqual(redacted_words, [2, 4, 6, 8])
Ejemplo n.º 16
0
    def test_punctuation(self):
        text_array = 'A a a jump over the dog.'.split()
        banned_word = ['dog']
        filter_array = redact_words(text_array, banned_word)

        assert 'dog.' not in filter_array