def testTypeOfLookupTableListReference(self):

        db = current.db

        uids = self.uids
        lookup_uids = self.lookup_uids
        resource = current.s3db.resource("typeof_hierarchy_reference")

        # Test with single value
        lookup = lookup_uids["NONHIERARCHY1"]
        expr = FS("typeof_hierarchy_id$typeof_nonhierarchy_multi_id").typeof(lookup)
        query = expr.query(resource)

        table = db.typeof_hierarchy
        expected = set(uids[uid] for uid in ("HIERARCHY2-1",
                                             "HIERARCHY2-1-1",
                                             "HIERARCHY2-1-2",
                                             ))
        expected_query = table.id.belongs(expected)

        # Test with multiple values
        lookup = (lookup_uids["NONHIERARCHY1"],
                  lookup_uids["NONHIERARCHY2"])
        expr = FS("typeof_hierarchy_id$typeof_nonhierarchy_multi_id").typeof(lookup)
        query = expr.query(resource)

        table = db.typeof_hierarchy
        expected = set(uids[uid] for uid in ("HIERARCHY2-1",
                                             "HIERARCHY2-1-1",
                                             "HIERARCHY2-1-2",
                                             ))
        expected_query = table.id.belongs(expected)

        self.assertEquivalent(query, expected_query)

    # -------------------------------------------------------------------------
Test resolution of __typeof queries, for list:reference field
dataset/ETHPy150Open sahana/eden/modules/unit_tests/s3/s3hierarchy.py/S3TypeOfTests.testTypeOfLookupTableListReference