'Check list of left joins in resource filters'

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

    s3db = current.s3db
    assertEqual = self.assertEqual
    assertTrue = self.assertTrue
    q = ((FS('organisation_id$name') == 'test') & (FS('task.description') == 'test'))
    resource = s3db.resource('project_project', filter=q)
    project_project = resource.table
    project_task_project = s3db.project_task_project
    project_task = s3db.project_task
    org_organisation = s3db.org_organisation
    expected1 = org_organisation.on((project_project.organisation_id == org_organisation.id))
    expected2 = project_task_project.on(((project_task_project.project_id == project_project.id) & (project_task_project.deleted != True)))
    expected3 = project_task.on((project_task_project.task_id == project_task.id))
    joins = resource.rfilter.get_joins(left=True)
    assertTrue(isinstance(joins, list))
    assertEqual(len(joins), 3)
    assertEqual(str(joins[0]), str(expected1))
    assertEqual(str(joins[1]), str(expected2))
    assertEqual(str(joins[2]), str(expected3))
