def getPropertyNames(self, rurl):

        assert(isinstance(rurl, URL))

        results = ()

        # Create WebDAV propfind
        request = PropNames(self, rurl.relativeURL(), headers.Depth0)
        result = ResponseDataString()
        request.setOutput(result)

        # Process it
        self.runSession(request)

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

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

            # Look at each propfind result
            for item in parser.getResults().itervalues():

                # Get child element name (decode URL)
                name = URL(url=item.getResource(), decode=True)

                # Must match rurl
                if name.equalRelative(rurl):

                    results = tuple([name for name in item.getNodeProperties().iterkeys()])

        else:
            self.handleHTTPError(request)

        return results
    def test_DepthInfinityHeaders(self):

        server = Session("www.example.com")
        request = PropNames(server, "/", headers.DepthInfinity)
        hdrs = request.generateRequestHeader()
        self.assertFalse("Depth: 0" in hdrs)
        self.assertFalse("Depth: 1" in hdrs)
        self.assertTrue("Depth: infinity" in hdrs)
    def test_GenerateXML(self):

        server = Session("www.example.com")
        request = PropNames(server, "/", headers.Depth0)
        os = StringIO()
        request.generateXML(os)
        self.assertEqual(os.getvalue(), """<?xml version='1.0' encoding='utf-8'?>
<ns0:propfind xmlns:ns0="DAV:">
  <ns0:propname />
</ns0:propfind>
""".replace("\n", "\r\n")
)
Exemple #4
0
    def getPropertyNames(self, rurl):

        assert (isinstance(rurl, URL))

        results = ()

        # Create WebDAV propfind
        request = PropNames(self, rurl.relativeURL(), headers.Depth0)
        result = ResponseDataString()
        request.setOutput(result)

        # Process it
        self.runSession(request)

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

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

            # Look at each propfind result
            for item in parser.getResults().itervalues():

                # Get child element name (decode URL)
                name = URL(url=item.getResource(), decode=True)

                # Must match rurl
                if name.equalRelative(rurl):

                    results = tuple(
                        [name for name in item.getNodeProperties().iterkeys()])

        else:
            self.handleHTTPError(request)

        return results
    def test_Method(self):

        server = Session("www.example.com")
        request = PropNames(server, "/", headers.Depth0)
        self.assertEqual(request.getMethod(), "PROPFIND")