Paste version information privately
This commit is contained in:
parent
cdf6f52d15
commit
53fb5af99c
@ -60,7 +60,7 @@ class PastebinClient(QObject):
|
|||||||
self._client = client
|
self._client = client
|
||||||
self._api_url = api_url
|
self._api_url = api_url
|
||||||
|
|
||||||
def paste(self, name, title, text, parent=None):
|
def paste(self, name, title, text, parent=None, private=False):
|
||||||
"""Paste the text into a pastebin and return the URL.
|
"""Paste the text into a pastebin and return the URL.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -68,6 +68,7 @@ class PastebinClient(QObject):
|
|||||||
title: The post title.
|
title: The post title.
|
||||||
text: The text to post.
|
text: The text to post.
|
||||||
parent: The parent paste to reply to.
|
parent: The parent paste to reply to.
|
||||||
|
private: Whether to paste privately.
|
||||||
"""
|
"""
|
||||||
data = {
|
data = {
|
||||||
'text': text,
|
'text': text,
|
||||||
@ -77,6 +78,9 @@ class PastebinClient(QObject):
|
|||||||
}
|
}
|
||||||
if parent is not None:
|
if parent is not None:
|
||||||
data['reply'] = parent
|
data['reply'] = parent
|
||||||
|
if private:
|
||||||
|
data['private'] = '1'
|
||||||
|
|
||||||
url = QUrl(urllib.parse.urljoin(self._api_url, 'create'))
|
url = QUrl(urllib.parse.urljoin(self._api_url, 'create'))
|
||||||
self._client.post(url, data)
|
self._client.post(url, data)
|
||||||
|
|
||||||
|
@ -486,4 +486,5 @@ def pastebin_version(pbclient=None):
|
|||||||
|
|
||||||
pbclient.paste(getpass.getuser(),
|
pbclient.paste(getpass.getuser(),
|
||||||
"qute version info {}".format(qutebrowser.__version__),
|
"qute version info {}".format(qutebrowser.__version__),
|
||||||
version())
|
version(),
|
||||||
|
private=True)
|
||||||
|
@ -79,6 +79,20 @@ def test_paste_without_parent(data, pbclient):
|
|||||||
assert http_stub.url == QUrl('https://crashes.qutebrowser.org/api/create')
|
assert http_stub.url == QUrl('https://crashes.qutebrowser.org/api/create')
|
||||||
|
|
||||||
|
|
||||||
|
def test_paste_private(pbclient):
|
||||||
|
data = {
|
||||||
|
"name": "the name",
|
||||||
|
"title": "the title",
|
||||||
|
"text": "some Text",
|
||||||
|
"apikey": "ihatespam",
|
||||||
|
"private": "1",
|
||||||
|
}
|
||||||
|
http_stub = pbclient._client
|
||||||
|
pbclient.paste(data["name"], data["title"], data["text"], private=True)
|
||||||
|
assert pbclient._client.data == data
|
||||||
|
assert http_stub.url == QUrl('https://crashes.qutebrowser.org/api/create')
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('http', [
|
@pytest.mark.parametrize('http', [
|
||||||
"http://paste.the-compiler.org/view/ges83nt3",
|
"http://paste.the-compiler.org/view/ges83nt3",
|
||||||
"http://paste.the-compiler.org/view/3gjnwg4"
|
"http://paste.the-compiler.org/view/3gjnwg4"
|
||||||
|
Loading…
Reference in New Issue
Block a user