예제 #1
0
 def test_parse_get_list_response(self):
     content = read_file_content('./tests/responses/get_list.xml')
     result = Utils.parse_get_list_response(content)
     self.assertEqual(result.__len__(), 2)
     self.assertTrue(result[0].is_dir(), '{} should be marked as directory'.format(result[0].path()))
     self.assertFalse(result[1].is_dir(), '{} should be marked as file'.format(result[1].path()))
     self.assertEqual(result[1].__str__(), '/test_dir/test.txt')
 def test_parse_get_list_response_dirs(self):
     content = read_file_content(
         './tests/responses/get_list_directories.xml')
     result = Utils.parse_get_list_response(content)
     self.assertEqual(result.__len__(), 5)
     for d in result:
         self.assertTrue(
             d.is_dir(),
             '{} should be marked as directory'.format(d.path()))
예제 #3
0
 def test_parse_get_list_response(self):
     content = '<?xml version="1.0" encoding="utf-8"?><d:multistatus xmlns:d="DAV:"><d:response><d:href>/test_dir/' \
               '</d:href><d:propstat><d:status>HTTP/1.1 200 OK</d:status><d:prop><d:resourcetype><d:collection/>' \
               '</d:resourcetype><d:getlastmodified>Mon, 16 Oct 2017 04:18:00 GMT</d:getlastmodified>' \
               '<d:displayname>test_dir</d:displayname><d:creationdate>2017-10-16T04:18:00Z</d:creationdate>' \
               '</d:prop></d:propstat></d:response><d:response><d:href>/test_dir/test.txt/</d:href><d:propstat>' \
               '<d:status>HTTP/1.1 200 OK</d:status><d:prop><d:resourcetype><d:collection/></d:resourcetype>' \
               '<d:getlastmodified>Mon, 16 Oct 2017 04:18:18 GMT</d:getlastmodified><d:displayname>test.txt' \
               '</d:displayname><d:creationdate>2017-10-16T04:18:18Z</d:creationdate></d:prop></d:propstat>' \
               '</d:response></d:multistatus>'
     result = utils.parse_get_list_response(content.encode('utf-8'))
     self.assertEqual(result.__len__(), 2)
예제 #4
0
    def list(self, remote_path=Client.root, get_info=False):
        # copy-pasted from the webdav lib with the non-needed additional http queries returned

        directory_urn = Urn(remote_path, directory=True)

        path = Urn.normalize_path(self.get_full_path(directory_urn))
        response = self.execute_request(action='list',
                                        path=directory_urn.quote())
        if get_info:
            subfiles = WebDavXmlUtils.parse_get_list_info_response(
                response.content)
            return [
                subfile for subfile in subfiles
                if Urn.compare_path(path, subfile.get('path')) is False
            ]

        urns = WebDavXmlUtils.parse_get_list_response(response.content)

        return [
            urn.filename() for urn in urns
            if Urn.compare_path(path, urn.path()) is False
        ]
 def test_parse_get_list_response_incorrect(self):
     content = read_file_content('./tests/responses/get_list_incorrect.xml')
     result = Utils.parse_get_list_response(content)
     self.assertEqual(result.__len__(), 0)