def test_startwith_double_found(self): """Matches both "dont_startwith" and "must_startwith" keywords, dont has more weight -> False""" teststring = "blabla helloworld blabla" f = ControlSession.buildfilter(input_to_string=str, dont_startwith=["xxxxx", "bla"], must_startwith=["xxxxx", "bla"], dont_contain=[], must_contain=[]) self.assertFalse(f(teststring))
def test_dont_startwith_found_second(self): """Line starts with second argument "dont_startwith"-keyword -> False""" teststring = "blabla helloworld blabla" f = ControlSession.buildfilter(input_to_string=str, dont_startwith=["xxxxx", "bla"], must_startwith=[], dont_contain=[], must_contain=[]) self.assertFalse(f(teststring))
def test_must_startwith_found_first(self): """Line starts with first argument "must_startwith"-keyword -> True""" teststring = "blabla helloworld blabla" f = ControlSession.buildfilter(input_to_string=str, dont_startwith=[], must_startwith=["bla", "xxxxx"], dont_contain=[], must_contain=[]) self.assertTrue(f(teststring))
def test_dont_contain_butfound(self): """One of "dont_contain"-keywords found -> False""" teststring = "blabla helloworld blabla" f = ControlSession.buildfilter(input_to_string=str, dont_startwith=[], must_startwith=[], dont_contain=["hello", "notworld"], must_contain=[]) self.assertFalse(f(teststring))
def test_contain2(self): """One of two "must_contain"-keywords is contained -> True""" teststring = "blabla helloworld blabla" f = ControlSession.buildfilter(input_to_string=str, dont_startwith=[], must_startwith=[], dont_contain=[], must_contain=["nothello", "world"]) self.assertTrue(f(teststring))
def test_contain1(self): """Single "must_contain"-keyword is contained -> True""" teststring = "blablahelloblabla" f = ControlSession.buildfilter(input_to_string=str, dont_startwith=[], must_startwith=[], dont_contain=[], must_contain=["hello"]) self.assertTrue(f(teststring))