Paste version information privately

This commit is contained in:
Florian Bruhin 2018-02-26 23:09:55 +01:00
parent cdf6f52d15
commit 53fb5af99c
3 changed files with 21 additions and 2 deletions

View File

@ -60,7 +60,7 @@ class PastebinClient(QObject):
self._client = client
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.
Args:
@ -68,6 +68,7 @@ class PastebinClient(QObject):
title: The post title.
text: The text to post.
parent: The parent paste to reply to.
private: Whether to paste privately.
"""
data = {
'text': text,
@ -77,6 +78,9 @@ class PastebinClient(QObject):
}
if parent is not None:
data['reply'] = parent
if private:
data['private'] = '1'
url = QUrl(urllib.parse.urljoin(self._api_url, 'create'))
self._client.post(url, data)

View File

@ -486,4 +486,5 @@ def pastebin_version(pbclient=None):
pbclient.paste(getpass.getuser(),
"qute version info {}".format(qutebrowser.__version__),
version())
version(),
private=True)

View File

@ -79,6 +79,20 @@ def test_paste_without_parent(data, pbclient):
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', [
"http://paste.the-compiler.org/view/ges83nt3",
"http://paste.the-compiler.org/view/3gjnwg4"