def calendarMultiGet(self, rurl, hrefs, props):
        """
        Fetches the specified props for the specified hrefs using a single
        multiget call. The return value is a dictionary where the keys are the
        hrefs and the values are PropFindResult objects containing results for
        the requested props.
        """

        assert(isinstance(rurl, URL))

        request = CalMultiget(self, rurl.relativeURL(), hrefs=hrefs, props=props)
        result = ResponseDataString()
        request.setOutput(result)

        # Process it
        self.runSession(request)

        # If it's a 207 we want to parse the XML
        if request.getStatusCode() == statuscodes.MultiStatus:

            parser = PropFindParser()
            parser.parseData(result.getData())
            return parser.getResults()

        else:
            self.handleHTTPError(request)
            return None
Example #2
0
    def calendarMultiGet(self, rurl, hrefs, props):
        """
        Fetches the specified props for the specified hrefs using a single
        multiget call. The return value is a dictionary where the keys are the
        hrefs and the values are PropFindResult objects containing results for
        the requested props.
        """

        assert (isinstance(rurl, URL))

        request = CalMultiget(self,
                              rurl.relativeURL(),
                              hrefs=hrefs,
                              props=props)
        result = ResponseDataString()
        request.setOutput(result)

        # Process it
        self.runSession(request)

        # If it's a 207 we want to parse the XML
        if request.getStatusCode() == statuscodes.MultiStatus:

            parser = PropFindParser()
            parser.parseData(result.getData())
            return parser.getResults()

        else:
            self.handleHTTPError(request)
            return None
    def test_GenerateXMLOneHrefOnly(self):

        server = Session("www.example.com")
        request = Multiget(server, "/", ("/a",))
        os = StringIO()
        request.generateXML(os)
        self.assertEqual(os.getvalue(), """<?xml version='1.0' encoding='utf-8'?>
<ns0:calendar-multiget xmlns:ns0="urn:ietf:params:xml:ns:caldav">
  <ns1:href xmlns:ns1="DAV:">/a</ns1:href>
</ns0:calendar-multiget>
""".replace("\n", "\r\n")
)
    def test_GenerateXMLOneHrefOnly(self):

        server = Session("www.example.com")
        request = Multiget(server, "/", ("/a",))
        os = StringIO()
        request.generateXML(os)
        self.assertEqual(
            os.getvalue(), """<?xml version='1.0' encoding='utf-8'?>
<ns0:calendar-multiget xmlns:ns0="urn:ietf:params:xml:ns:caldav">
  <ns1:href xmlns:ns1="DAV:">/a</ns1:href>
</ns0:calendar-multiget>
""".replace("\n", "\r\n")
        )
    def test_GenerateXMLMultipleHrefsMultipleProperties(self):

        server = Session("www.example.com")
        request = Multiget(server, "/", ("/a", "/b",), (davxml.getetag, davxml.displayname,))
        os = StringIO()
        request.generateXML(os)
        self.assertEqual(os.getvalue(), """<?xml version='1.0' encoding='utf-8'?>
<ns0:calendar-multiget xmlns:ns0="urn:ietf:params:xml:ns:caldav">
  <ns1:prop xmlns:ns1="DAV:">
    <ns1:getetag />
    <ns1:displayname />
  </ns1:prop>
  <ns1:href xmlns:ns1="DAV:">/a</ns1:href>
  <ns1:href xmlns:ns1="DAV:">/b</ns1:href>
</ns0:calendar-multiget>
""".replace("\n", "\r\n")
)
    def test_GenerateXMLMultipleHrefsMultipleProperties(self):

        server = Session("www.example.com")
        request = Multiget(server, "/", ("/a", "/b",), (davxml.getetag, davxml.displayname,))
        os = StringIO()
        request.generateXML(os)
        self.assertEqual(
            os.getvalue(), """<?xml version='1.0' encoding='utf-8'?>
<ns0:calendar-multiget xmlns:ns0="urn:ietf:params:xml:ns:caldav">
  <ns1:prop xmlns:ns1="DAV:">
    <ns1:getetag />
    <ns1:displayname />
  </ns1:prop>
  <ns1:href xmlns:ns1="DAV:">/a</ns1:href>
  <ns1:href xmlns:ns1="DAV:">/b</ns1:href>
</ns0:calendar-multiget>
""".replace("\n", "\r\n")
        )
Example #7
0
    def doRequest(self):
        """
        Execute the actual HTTP request.
        """
        hrefs = [
            joinURL(self.sessions[0].calendarHref, "%d.ics" % (i + 1, ))
            for i in range(self.count)
        ]
        props = (
            davxml.getetag,
            caldavxml.calendar_data,
            caldavxml.schedule_tag,
        )

        # Create CalDAV multiget
        request = Multiget(self.sessions[0], self.sessions[0].calendarHref,
                           hrefs, props)
        result = ResponseDataString()
        request.setOutput(result)

        # Process it
        self.sessions[0].runSession(request)

        # If its a 207 we want to parse the XML
        if request.getStatusCode() == statuscodes.MultiStatus:
            pass
        else:
            raise RuntimeError("Muliget request failed: %s" %
                               (request.getStatusCode(), ))
Example #8
0
    def doRequest(self):
        """
        Execute the actual HTTP request.
        """
        hrefs = [joinURL(self.sessions[0].calendarHref, "%d.ics" % (i+1,)) for i in range(self.count)]
        props = (
            davxml.getetag,
            caldavxml.calendar_data,
            caldavxml.schedule_tag,
        )

        # Create CalDAV multiget
        request = Multiget(self.sessions[0], self.sessions[0].calendarHref, hrefs, props)
        result = ResponseDataString()
        request.setOutput(result)
    
        # Process it
        self.sessions[0].runSession(request)
    
        # If its a 207 we want to parse the XML
        if request.getStatusCode() == statuscodes.MultiStatus:
            pass
        else:
            raise RuntimeError("Muliget request failed: %s" % (request.getStatusCode(),))
    def test_Method(self):

        server = Session("www.example.com")
        request = Multiget(server, "/", ())
        self.assertEqual(request.getMethod(), "REPORT")
    def test_Method(self):

        server = Session("www.example.com")
        request = Multiget(server, "/", ())
        self.assertEqual(request.getMethod(), "REPORT")