def test_from_list_and(self): """Test the formation of a filters from a given list of filters using the and operator.""" fs = [LFG.next() for x in xrange(random.randint(2,30))] combination = LdapFilter.from_list(lambda x, y: x & y, fs) combination_string = "%s" % (combination) self.assertTrue(len(combination_string) <= 3 + sum(map(lambda f: len("%s" % (f)), fs))) self.assertTrue(combination_string[0] == '(') self.assertTrue(combination_string[1] == '&') self.assertTrue(combination_string[-1] == ')')
def test_from_list_and(self): """Test the formation of a filters from a given list of filters using the and operator.""" fs = [LFG.next() for x in range(random.randint(2, 30))] combination = LdapFilter.from_list(lambda x, y: x & y, fs) combination_string = "%s" % (combination) self.assertTrue( len(combination_string) <= 3 + sum(map(lambda f: len("%s" % (f)), fs))) self.assertTrue(combination_string[0] == '(') self.assertTrue(combination_string[1] == '&') self.assertTrue(combination_string[-1] == ')')
def test_from_list_and(self, fs): """Test the formation of a filters from a given list of filters using the and operator.""" if not fs or len(fs) < 2: return combination = LdapFilter.from_list(lambda x, y: x & y, fs) combination_string = "%s" % (combination) self.assertTrue(len(combination_string) <= 3 + sum(map(lambda f: len("%s" % (f)), fs))) self.assertTrue(combination_string[0] == '(') self.assertTrue(combination_string[1] == '&') self.assertTrue(combination_string[-1] == ')')