def testHierarchyFilterTypeOf(self):

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

        filter_widget = S3HierarchyFilter("typeof_hierarchy_id")

        # Test with belongs on filter field
        ids = str(uids["HIERARCHY1-1"])
        get_vars = {"~.typeof_hierarchy_id__belongs": ids}
        variable = filter_widget.variable(resource, get_vars)
        expected = set(ids)
        values = filter_widget._values(get_vars, variable)
        self.assertEqual(values, [ids])

        # Test with typeof on filter field
        ids = str(uids["HIERARCHY1-1"])
        get_vars = {"~.typeof_hierarchy_id__typeof": ids}
        variable = filter_widget.variable(resource, get_vars)
        expected = set(str(uids[uid]) for uid in ("HIERARCHY1-1",
                                                  "HIERARCHY1-1-1",
                                                  "HIERARCHY1-1-2",
                                                  ))
        values = filter_widget._values(get_vars, variable)
        self.assertEqual(set(values), expected)

        # Test with typeof on filter field, multiple values incl. None
        ids = ",".join(str(_id) for _id in (uids["HIERARCHY1-1"],
                                            uids["HIERARCHY2-1"],
                                            None))
        get_vars = {"~.typeof_hierarchy_id__typeof": ids}
        variable = filter_widget.variable(resource, get_vars)
        expected = set(str(uids[uid]) for uid in ("HIERARCHY1-1",
                                                  "HIERARCHY1-1-1",
                                                  "HIERARCHY1-1-2",
                                                  "HIERARCHY2-1",
                                                  "HIERARCHY2-1-1",
                                                  "HIERARCHY2-1-2",
                                                  ))
        expected.add(None)
        values = filter_widget._values(get_vars, variable)
        self.assertEqual(set(values), expected)

        # Test with typeof on field in lookup table
        get_vars = {"~.typeof_hierarchy_id$name__typeof": "Type 1-1"}
        variable = filter_widget.variable(resource, get_vars)
        expected = set(str(uids[uid]) for uid in ("HIERARCHY1-1",
                                                  "HIERARCHY1-1-1",
                                                  "HIERARCHY1-1-2",
                                                  ))
        values = filter_widget._values(get_vars, variable)
        self.assertEqual(set(values), expected)

        # Test with typeof on field in lookup table, multiple values
        get_vars = {"~.typeof_hierarchy_id$name__typeof": "Type 1-1,Type 2-1"}
        variable = filter_widget.variable(resource, get_vars)
        expected = set(str(uids[uid]) for uid in ("HIERARCHY1-1",
                                                  "HIERARCHY1-1-1",
                                                  "HIERARCHY1-1-2",
                                                  "HIERARCHY2-1",
                                                  "HIERARCHY2-1-1",
                                                  "HIERARCHY2-1-2",
                                                  ))
        values = filter_widget._values(get_vars, variable)
        self.assertEqual(set(values), expected)

        # Test with typeof on field in lookup table, unresolvable
        get_vars = {"~.typeof_hierarchy_id$name__typeof": "Type 1-3"}
        variable = filter_widget.variable(resource, get_vars)
        expected = set()
        values = filter_widget._values(get_vars, variable)
        self.assertEqual(set(values), expected)

        # Test with typeof on field in lookup table, None
        get_vars = {"~.typeof_hierarchy_id$name__typeof": "None"}
        variable = filter_widget.variable(resource, get_vars)
        expected = set()
        values = filter_widget._values(get_vars, variable)
        self.assertEqual(set(values), expected)

        # Test preferrence of belongs in mixed queries
        ids = str(uids["HIERARCHY1-1"])
        get_vars = {"~.typeof_hierarchy_id__belongs": ids,
                    "~.typeof_hierarchy_id$name__typeof": "Type 1-1",
                    }
        variable = filter_widget.variable(resource, get_vars)
        expected = set(ids)
        values = filter_widget._values(get_vars, variable)
        self.assertEqual(values, [ids])

    # -------------------------------------------------------------------------
Returns an XML Schema sub-sequence (complex type, then sequence)
dataset/ETHPy150Open sahana/eden/modules/unit_tests/s3/s3hierarchy.py/S3TypeOfTests.testHierarchyFilterTypeOf--crossover with--dataset/ETHPy150Open jahlborn/appengine-rest-server/src/main/python/rest/__init__.py/xsd_append_sequence