-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
This diff should be possible with more code moved to cruizlib
diff --git a/src/cruiz/commands/metarequestconaninvocation.py b/src/cruiz/commands/metarequestconaninvocation.py
index 0fc2779..0a6ed09 100755
--- a/src/cruiz/commands/metarequestconaninvocation.py
+++ b/src/cruiz/commands/metarequestconaninvocation.py
@@ -109,6 +109,17 @@ class MetaRequestConanInvocation(QtCore.QObject):
logger.critical("Conan has leaked into cruiz")
sys.exit(1)
+ @staticmethod
+ def encode_request(
+ request: typing.Any, params: typing.Optional[typing.Dict[str, typing.Any]]
+ ) -> str:
+ """Encode a request string and any parameters."""
+ return (
+ f"{request}?{urllib.parse.urlencode(params, doseq=True)}"
+ if params
+ else request
+ )
+
def request_data(
self,
request: typing.Any,
@@ -119,11 +130,7 @@ class MetaRequestConanInvocation(QtCore.QObject):
Reply is a tuple, with result and exception.
"""
- meta_request = (
- f"{request}?{urllib.parse.urlencode(params, doseq=True)}"
- if params
- else request
- )
+ meta_request = MetaRequestConanInvocation.encode_request(request, params)
logger.debug("* Requesting %s", meta_request)
self._request_queue.put(meta_request)
self.active = True
diff --git a/tests/workers/test_meta.py b/tests/workers/test_meta.py
index f8e36b4..209dcd1 100644
--- a/tests/workers/test_meta.py
+++ b/tests/workers/test_meta.py
@@ -4,7 +4,8 @@ from __future__ import annotations
import logging
import typing
-import urllib.parse
+
+from cruiz.commands.metarequestconaninvocation import MetaRequestConanInvocation
from cruizlib.globals import CONAN_FULL_VERSION, CONAN_MAJOR_VERSION
from cruizlib.interop.message import (
@@ -124,9 +125,8 @@ def test_meta_remotes_sync(
ConanRemote("ARemote", "http://a.remote.com", True),
ConanRemote("BRemote", "http://b.remote.com", False),
]
- payload = {"remotes": new_remotes}
- remotes_sync_request = (
- f"remotes_sync?{urllib.parse.urlencode(payload, doseq=True)}"
+ remotes_sync_request = MetaRequestConanInvocation.encode_request(
+ "remotes_sync", {"remotes": new_remotes}
)
request_queue.put(remotes_sync_request)
However, as it stands, there's a dependency on GUI PySide because of other parts of cruiz that comes in.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels