Ejemplo n.º 1
0
def test_many_to_one(site):
    """Test many to one relationship traversals."""
    request = {"second_ap.code": "BBB"}
    results = list(
        site.view("first_ap", {"scode": "second_ap.code"}, request=request))
    eq_(len(results), 2)
    assert all((result["scode"] == "BBB" for result in results))
    query = QueryFilter(make_request(request))
    results = list(site.view("first_ap", query=query))
    eq_(len(results), 2)
Ejemplo n.º 2
0
    def item_from_xml(self, elem):
        """Build an item from an element representing an item.

        Subclasses may override this method according to their XML
        serialization mechanism.

        """
        request_dict = dict(((child.tag, child.text) for child in elem))
        if request_dict:
            request = normalize(
                self.remote_ap.properties, make_request(request_dict))
            return (self.remote_ap.open(request),)
        else:
            return (None,)