'Test counting rows with ambiguous query'

def testCountRows(self):

    s3db = current.s3db
    assertEqual = self.assertEqual
    query = (FS('name') == 'DATestOrg')
    resource = s3db.resource('org_organisation', filter=query)
    resource.add_filter(query)
    assertEqual(resource.select(['id'], count=True).numrows, 1)
    query = FS('office.name').like('DATestOffice%')
    resource = s3db.resource('org_organisation', filter=query)
    assertEqual(resource.count(), 1)
    resource = s3db.resource('org_organisation')
    class FakeVirtualFields(object, ):
        def testfield(self):
            return 'TEST'
    resource.table.virtualfields.append(FakeVirtualFields())
    query = (query & (FS('testfield') == 'TEST'))
    resource.add_filter(query)
    assertEqual(resource.count(), 1)
