'Test selection with virtual filter'

def testSelectVirtualFilter(self):

    s3db = current.s3db
    assertTrue = self.assertTrue
    assertEqual = self.assertEqual
    numitems = len([item for item in self.test_data if (item[1] == 'A')])
    query = (FS('code') == 'A')
    resource = s3db.resource('select_master', filter=query)
    data = resource.select(['name', 'status'])
    rows = data.rows
    assertEqual(len(rows), numitems)
    assertTrue(all(((row['select_master.status'] == 'A') 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])
