'Test Representation of reference, single value,
with linkto'

def testRepresentReferenceSingleLinktoOn(self):

    s3db = current.s3db
    tablename = self.tablename
    fname = ('%s.organisation_id' % tablename)
    fac = self.facs[0]
    resource = s3db.resource(tablename, id=fac.id)
    renderer = S3Represent(lookup='org_organisation', show_link=True)
    table = resource.table
    table.organisation_id.represent = renderer
    data = resource.select(['id', 'organisation_id'], limit=None, represent=True)
    result = data['rows']
    self.assertEqual(renderer.queries, 1)
    self.assertTrue(isinstance(result, list))
    self.assertEqual(len(result), 1)
    output = result[0]
    self.assertTrue(isinstance(output, Storage))
    self.assertTrue((fname in output))
    representation = output[fname]
    self.assertTrue(isinstance(representation, A))
    self.assertEqual(representation.attributes['_href'], ('/%s/org/organisation/%s' % (current.request.application, self.org.id)))
    self.assertEqual(representation.components[0], self.org.name)
