'Test resolution of __typeof queries, for field in referencing
table, with single value'

def testTypeOfReferenceSingle(self):

    db = current.db
    uids = self.uids
    resource = current.s3db.resource('typeof_hierarchy_reference')
    expr = FS('typeof_hierarchy_id').typeof(uids['HIERARCHY1'])
    query = expr.query(resource)
    table = resource.table
    expected = set((uids[uid] for uid in ('HIERARCHY1', 'HIERARCHY1-1', 'HIERARCHY1-1-1', 'HIERARCHY1-1-2', 'HIERARCHY1-2', 'HIERARCHY1-2-1', 'HIERARCHY1-2-2')))
    expected_query = table.typeof_hierarchy_id.belongs(expected)
    self.assertEquivalent(query, expected_query)
