def test_get_filters_lambda(self): filters = Filters() result = filters.get_filters(lambda x: x=='village') exp = "village != 'UNKNOWN'" self.assertEqual(result, exp, 'Get from empty filters, lambda matches') result = filters.get_filters(lambda x: x == '(*^&*&%^') exp = "" self.assertEqual(result, exp, 'Get from empty filters, lambda does not match')
def test_get_filters_after_add(self): filters = Filters() filters.add_filter('project', ['XYZ']) result = filters.get_filters(lambda x: True) # don't know what order they will be, but there should be 2 lines split = result.split('\n') self.assertEqual(len(split), 2, 'Filter with project, True, should have two phrases') filters.add_filter('categoryid', ['query = my query', 'query=other query']) result = filters.get_filters(lambda x: True) # there is no column flavor # should be 3 lines split = result.split('\n') self.assertEqual(len(split), 3, 'Filter with project, 2 content queries, True, should have three phrases')
def test_get_filters_false(self): filters = Filters() result = filters.get_filters(lambda x: False) exp = "" self.assertEqual(result, exp, 'Get from empty filters, False')
def test_get_filters_true(self): filters = Filters() result = filters.get_filters(lambda x: True) exp = "village != 'UNKNOWN'" self.assertEqual(result, exp, 'Get from empty filters, True')