def test_parse_get_list_info_response(self):
     content = read_file_content('./tests/responses/get_list_info.xml')
     result = Utils.parse_get_list_info_response(content)
     print(result)
     self.assertEqual(result[0]['created'], '2017-10-18T15:16:04Z')
     self.assertEqual(result[0]['name'], 'test.txt')
     self.assertEqual(result[0]['modified'],
                      'Wed, 18 Oct 2017 15:16:04 GMT')
     self.assertEqual(result[0]['size'], '41')
     self.assertEqual(result[0]['etag'], 'ab0b4b7973803c03639b848682b5f38c')
     self.assertEqual(result[0]['isdir'], False)
     self.assertEqual(result[0]['path'], '/test_dir/test.txt')
示例#2
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
        ]