'Test combinations of web2py Queries with S3ResourceQueries'

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

    s3db = current.s3db
    assertEqual = self.assertEqual
    assertTrue = self.assertTrue
    resource = s3db.resource('project_project')
    q = ((FS('organisation_id$name') == 'test') & (resource.table.name == 'test'))
    (joins, distinct) = q._joins(resource)
    assertEqual(joins.keys(), [])
    project_project = resource.table
    project_task_project = s3db.project_task_project
    project_task = s3db.project_task
    org_organisation = s3db.org_organisation
    expected = org_organisation.on((project_project.organisation_id == org_organisation.id))
    (joins, distinct) = q._joins(resource, left=True)
    assertEqual(joins.keys(), ['org_organisation'])
    assertTrue(isinstance(joins['org_organisation'], list))
    assertEqual(len(joins['org_organisation']), 1)
    assertEqual(str(joins['org_organisation'][0]), str(expected))
    assertTrue(distinct)
    (qq, qf) = q.split(resource)
    assertEqual(qf, None)
    query = qq.query(resource)
    expected = ((org_organisation.name == 'test') & (project_project.name == 'test'))
    assertEqual(str(query), str(expected))
    resource.add_filter(q)
    query = resource.get_query()
    expected = (((project_project.deleted != True) & (project_project.id > 0)) & ((org_organisation.name == 'test') & (project_project.name == 'test')))
    assertEqual(str(query), str(expected))
