def testApplyExtraFilter(self):

        assertTrue = self.assertTrue
        assertEqual = self.assertEqual
        assertNotEqual = self.assertNotEqual

        test_expression = "test filter expression"
        seen = []

        def test_filter(resource, ids, expression):
            """ Test filter method """

            # Check resource
            assertNotEqual(resource, None)
            assertEqual(resource.tablename, "select_master")

            # Verify that the resource has no extra filters while
            # extra filters are applied
            efilters = resource.rfilter.efilters
            assertEqual(efilters, [])

            # Check ids
            assertTrue(type(ids) is list)
            assertNotEqual(len(ids), 0)

            # Remember ids to verify that no unnecessary items are passed
            #print "called with %s" % str(ids)
            seen.extend(ids)

            # Verify correct expression is passed
            assertEqual(expression, test_expression)

            # Filter ids to verify that filter is effective
            result = [item for item in ids if item > 3 and item % 2 == 0]

            # Add a duplicate to verify that duplicates do not affect
            # match counting and do not appear in the subset
            if result:
                result.insert(0, result[-1])

            # Reverse result list to verify that original order is restored
            result.reverse()

            return result

        # Define resource, add test filter as extra filter
        resource = current.s3db.resource("select_master")
        resource.add_extra_filter(test_filter, test_expression)

        apply_extra_filters = resource.rfilter.apply_extra_filters

        # Fake set of record IDs
        test_set = [1, 2, 3, 4, 5, 6, 7, 8]

        # Test without limit
        seen = []
        subset = apply_extra_filters(test_set)
        assertEqual(subset, [4, 6, 8])
        assertEqual(seen, test_set)

        # Test with limit < len(test_set)
        seen = []
        subset = apply_extra_filters(test_set, limit=2)
        assertEqual(subset, [4, 6])
        assertEqual(seen, [1, 2, 3, 4, 5, 6])

        # Test with limit > len(test_set)
        seen = []
        subset = apply_extra_filters(test_set, limit=10)
        assertEqual(subset, [4, 6, 8])
        assertEqual(seen, test_set)

    # -------------------------------------------------------------------------
set_done_update_hook(hook: function(pipeline, objects)) -> None
dataset/ETHPy150Open sahana/eden/modules/unit_tests/s3/s3resource.py/ResourceSelectTests.testApplyExtraFilter--crossover with--dataset/ETHPy150Open VisTrails/VisTrails/vistrails/core/interpreter/base.py/BaseInterpreter.set_done_update_hook