def test_add_properties(self):
        adapter = getAdapter(None, IPROPFINDDocumentGenerator)
        document = adapter.create_document()

        provider = ExampleProperties(None, None)
        adapter.add_response(document, provider)

        self.assertEquals(
            normalize_xml(PROPFIND_RESPONSE_TEMPLATE % (
                    ''.join((PROPFIND_DISPLAYNAME, PROPFIND_RESOURCETYPE)))),
            normalize_xml(etree.tostring(document)))
    def test_generate_all_properties(self):
        request_data = ''.join((
                '<d:propfind xmlns:d="DAV:">',
                '  <d:allprop/>',
                '</d:propfind>'))

        request = self.layer['request']
        request.set('BODY', request_data)

        provider = ExampleProperties(None, None)
        adapter = getAdapter(self.layer['request'], IPROPFINDDocumentGenerator)
        adapter.generate([provider])

        self.assertEquals(207, request.RESPONSE.getStatus())
        self.assertEquals(
            normalize_xml(PROPFIND_RESPONSE_TEMPLATE % ''.join((
                        PROPFIND_DISPLAYNAME, PROPFIND_RESOURCETYPE))),
            normalize_xml(request.RESPONSE.body))
    def test_generate_list_names(self):
        request_data = ''.join((
                '<d:propfind xmlns:d="DAV:">',
                '  <d:propname/>',
                '</d:propfind>'))

        request = self.layer['request']
        request.set('BODY', request_data)

        provider = ExampleProperties(None, None)
        adapter = getAdapter(self.layer['request'], IPROPFINDDocumentGenerator)
        adapter.generate([provider])

        self.assertEquals(207, request.RESPONSE.getStatus())
        self.assertEquals(
            normalize_xml(PROPFIND_RESPONSE_TEMPLATE % ''.join((
                        '<dav:displayname/>',
                        '<dav:resourcetype/>'))),
            normalize_xml(request.RESPONSE.body))