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_add_filter_add_undefined(self): filters = Filters() v = filters.add_filter('bogus', ['XYZ']) self.assertFalse(v, 'Attempt to add bogus filter should return false') self.assertEqual(len(filters.column_filters), 1, 'Add one bogus item')
def test_add_filter_add_then_remove_village(self): filters = Filters() filters.add_filter('village', ['XYZ']) filters.add_filter('village', []) self.assertEqual(len(filters.column_filters), 1, 'Add one item, then remove it')
def test_add_filter_same_village(self): filters = Filters() filters.add_filter('village', ['XYZ']) filters.add_filter('village', ['XYZ']) self.assertEqual(len(filters.column_filters), 1, 'Add one item twice')
def test_add_filter_same(self): filters = Filters() filters.add_filter('project', ['XYZ']) filters.add_filter('project', ['XYZ']) self.assertEqual(len(filters.column_filters), 2, 'Add one item twice')
def test_add_filter_one(self): filters = Filters() v = filters.add_filter('project', ['XYZ']) self.assertTrue(v, 'Add item should return true') self.assertEqual(len(filters.column_filters), 2, 'Add one item')