mirror of
https://github.com/fergalmoran/picard.git
synced 2026-01-06 08:34:01 +00:00
qurl -> url, and convert to Qurl is passed as a string
This commit is contained in:
@@ -107,7 +107,7 @@ class WSRequest(QNetworkRequest):
|
||||
priority=False,
|
||||
important=False,
|
||||
request_mimetype=None,
|
||||
qurl=None,
|
||||
url=None,
|
||||
):
|
||||
"""
|
||||
Args:
|
||||
@@ -126,7 +126,7 @@ class WSRequest(QNetworkRequest):
|
||||
priority: Indicates that this is a high priority request.
|
||||
important: Indicates that this is an important request.
|
||||
request_mimetype: Set the Content-Type header.
|
||||
qurl: QUrl object to use for this request
|
||||
url: URL passed as a string or as a QUrl to use for this request
|
||||
"""
|
||||
# These two are codependent (see _update_authorization_header) and must
|
||||
# be initialized explicitly.
|
||||
@@ -142,10 +142,12 @@ class WSRequest(QNetworkRequest):
|
||||
if self.handler is None:
|
||||
raise AssertionError('handler undefined')
|
||||
|
||||
if qurl is None:
|
||||
if url is None:
|
||||
raise AssertionError('URL undefined')
|
||||
|
||||
super().__init__(qurl)
|
||||
if not isinstance(url, QUrl):
|
||||
url = QUrl(url)
|
||||
super().__init__(url)
|
||||
|
||||
# optional parameters
|
||||
self.parse_response_type = parse_response_type
|
||||
@@ -462,7 +464,7 @@ class WebService(QtCore.QObject):
|
||||
|
||||
redirect_request = WSRequest(
|
||||
method='GET',
|
||||
qurl=redirect_qurl,
|
||||
url=redirect_qurl,
|
||||
handler=request.handler,
|
||||
parse_response_type=request.parse_response_type,
|
||||
priority=True,
|
||||
@@ -564,7 +566,7 @@ class WebService(QtCore.QObject):
|
||||
queryargs=None):
|
||||
request = WSRequest(
|
||||
method='GET',
|
||||
qurl=build_qurl(host, port, path=path, queryargs=queryargs),
|
||||
url=build_qurl(host, port, path=path, queryargs=queryargs),
|
||||
handler=handler,
|
||||
parse_response_type=parse_response_type,
|
||||
priority=priority,
|
||||
@@ -579,7 +581,7 @@ class WebService(QtCore.QObject):
|
||||
priority=False, important=False, mblogin=True, queryargs=None, request_mimetype=None):
|
||||
request = WSRequest(
|
||||
method='POST',
|
||||
qurl=build_qurl(host, port, path=path, queryargs=queryargs),
|
||||
url=build_qurl(host, port, path=path, queryargs=queryargs),
|
||||
handler=handler,
|
||||
parse_response_type=parse_response_type,
|
||||
priority=priority,
|
||||
@@ -595,7 +597,7 @@ class WebService(QtCore.QObject):
|
||||
queryargs=None, request_mimetype=None):
|
||||
request = WSRequest(
|
||||
method='PUT',
|
||||
qurl=build_qurl(host, port, path=path, queryargs=queryargs),
|
||||
url=build_qurl(host, port, path=path, queryargs=queryargs),
|
||||
handler=handler,
|
||||
priority=priority,
|
||||
important=important,
|
||||
@@ -609,7 +611,7 @@ class WebService(QtCore.QObject):
|
||||
queryargs=None):
|
||||
request = WSRequest(
|
||||
method='DELETE',
|
||||
qurl=build_qurl(host, port, path=path, queryargs=queryargs),
|
||||
url=build_qurl(host, port, path=path, queryargs=queryargs),
|
||||
handler=handler,
|
||||
priority=priority,
|
||||
important=important,
|
||||
@@ -622,7 +624,7 @@ class WebService(QtCore.QObject):
|
||||
queryargs=None):
|
||||
request = WSRequest(
|
||||
method='GET',
|
||||
qurl=build_qurl(host, port, path=path, queryargs=queryargs),
|
||||
url=build_qurl(host, port, path=path, queryargs=queryargs),
|
||||
handler=handler,
|
||||
priority=priority,
|
||||
important=important,
|
||||
|
||||
@@ -28,7 +28,6 @@ from unittest.mock import (
|
||||
patch,
|
||||
)
|
||||
|
||||
from PyQt5.QtCore import QUrl
|
||||
from PyQt5.QtNetwork import QNetworkProxy
|
||||
|
||||
from test.picardtestcase import PicardTestCase
|
||||
@@ -115,7 +114,7 @@ class WebServiceTaskTest(PicardTestCase):
|
||||
def test_add_task(self):
|
||||
request = WSRequest(
|
||||
method='GET',
|
||||
qurl=QUrl('http://abc.xyz'),
|
||||
url='http://abc.xyz',
|
||||
handler=dummy_handler,
|
||||
)
|
||||
func = 1
|
||||
@@ -131,7 +130,7 @@ class WebServiceTaskTest(PicardTestCase):
|
||||
mock_timer2 = self.ws._timer_count_pending_requests
|
||||
request = WSRequest(
|
||||
method='GET',
|
||||
qurl=QUrl('http://abc.xyz'),
|
||||
url='http://abc.xyz',
|
||||
handler=dummy_handler,
|
||||
)
|
||||
self.ws.add_task(0, request)
|
||||
@@ -180,7 +179,7 @@ class RequestTaskTest(PicardTestCase):
|
||||
def test_from_request(self):
|
||||
request = WSRequest(
|
||||
method='GET',
|
||||
qurl=QUrl('https://example.com'),
|
||||
url='https://example.com',
|
||||
handler=dummy_handler,
|
||||
priority=True,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user