'Test selection with extra filter'

def testSelectExtraFilter(self):

    db = current.db
    s3db = current.s3db
    assertTrue = self.assertTrue
    assertEqual = self.assertEqual
    test_expression = 'A'
    numitems = len([item for item in self.test_data if (item[1] == test_expression)])
    def test_filter(resource, ids, expression):
        '    Test    filter    function    '
        assertEqual(expression, test_expression)
        table = resource.table
        query = (table.id.belongs(ids) & (table.status == expression))
        rows = db(query).select(table.id)
        return [row.id for row in rows]
    resource = s3db.resource('select_master', extra_filters=[(test_filter, test_expression)])
    data = resource.select(['name', 'status'])
    rows = data.rows
    assertEqual(len(rows), numitems)
    assertTrue(all(((row['select_master.status'] == test_expression) for row in rows)))
    data = resource.select(['name', 'status'], count=True)
    assertEqual(len(data.rows), data.numrows)
    data = resource.select(['id', 'name', 'status'], getids=True)
    rows = data.rows
    ids = data.ids
    assertEqual(len(rows), len(ids))
    for (index, row) in enumerate(rows):
        assertEqual(row['select_master.id'], ids[index])
