'Resolution of a selector for a field in a referenced table'

@unittest.skipIf((not current.deployment_settings.has_module('project')), 'project    module    disabled')
def testResolveSelectorReferencedTableField(self):

    assertEqual = self.assertEqual
    assertNotEqual = self.assertNotEqual
    assertTrue = self.assertTrue
    s3db = current.s3db
    project_project = s3db.project_project
    org_organisation = s3db.org_organisation
    resource = s3db.resource('project_project')
    selector = 'organisation_id$name'
    f = S3ResourceField(resource, selector)
    assertNotEqual(f, None)
    assertEqual(f.selector, selector)
    assertEqual(str(f.field), 'org_organisation.name')
    assertEqual(str(f.tname), 'org_organisation')
    assertEqual(str(f.fname), 'name')
    assertEqual(str(f.colname), 'org_organisation.name')
    assertTrue(isinstance(f.left['org_organisation'], list))
    assertEqual(len(f.left['org_organisation']), 1)
    expected = org_organisation.on((project_project.organisation_id == org_organisation.id))
    assertEqual(str(f.left['org_organisation'][0]), str(expected))
    expected = (project_project.organisation_id == org_organisation.id)
    assertEqual(str(f.join['org_organisation']), str(expected))
    assertTrue(f.distinct)
