mirror of
https://github.com/ihabunek/toot.git
synced 2024-11-03 04:17:21 -05:00
Make verify_credentials return the http response
Required if we want to emit json without decoding it
This commit is contained in:
parent
317840b019
commit
6cdba16fcf
@ -12,7 +12,7 @@ def test_update_account_display_name(run, app, user):
|
||||
out = run("update_account", "--display-name", "elwood")
|
||||
assert out == "✓ Account updated"
|
||||
|
||||
account = api.verify_credentials(app, user)
|
||||
account = api.verify_credentials(app, user).json()
|
||||
assert account["display_name"] == "elwood"
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@ def test_update_account_note(run, app, user):
|
||||
out = run("update_account", "--note", note)
|
||||
assert out == "✓ Account updated"
|
||||
|
||||
account = api.verify_credentials(app, user)
|
||||
account = api.verify_credentials(app, user).json()
|
||||
assert get_text(account["note"]) == note
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@ def test_update_account_language(run, app, user):
|
||||
out = run("update_account", "--language", "hr")
|
||||
assert out == "✓ Account updated"
|
||||
|
||||
account = api.verify_credentials(app, user)
|
||||
account = api.verify_credentials(app, user).json()
|
||||
assert account["source"]["language"] == "hr"
|
||||
|
||||
|
||||
@ -39,29 +39,29 @@ def test_update_account_privacy(run, app, user):
|
||||
out = run("update_account", "--privacy", "private")
|
||||
assert out == "✓ Account updated"
|
||||
|
||||
account = api.verify_credentials(app, user)
|
||||
account = api.verify_credentials(app, user).json()
|
||||
assert account["source"]["privacy"] == "private"
|
||||
|
||||
|
||||
def test_update_account_avatar(run, app, user):
|
||||
account = api.verify_credentials(app, user)
|
||||
account = api.verify_credentials(app, user).json()
|
||||
old_value = account["avatar"]
|
||||
|
||||
out = run("update_account", "--avatar", TRUMPET)
|
||||
assert out == "✓ Account updated"
|
||||
|
||||
account = api.verify_credentials(app, user)
|
||||
account = api.verify_credentials(app, user).json()
|
||||
assert account["avatar"] != old_value
|
||||
|
||||
|
||||
def test_update_account_header(run, app, user):
|
||||
account = api.verify_credentials(app, user)
|
||||
account = api.verify_credentials(app, user).json()
|
||||
old_value = account["header"]
|
||||
|
||||
out = run("update_account", "--header", TRUMPET)
|
||||
assert out == "✓ Account updated"
|
||||
|
||||
account = api.verify_credentials(app, user)
|
||||
account = api.verify_credentials(app, user).json()
|
||||
assert account["header"] != old_value
|
||||
|
||||
|
||||
@ -69,13 +69,13 @@ def test_update_account_locked(run, app, user):
|
||||
out = run("update_account", "--locked")
|
||||
assert out == "✓ Account updated"
|
||||
|
||||
account = api.verify_credentials(app, user)
|
||||
account = api.verify_credentials(app, user).json()
|
||||
assert account["locked"] is True
|
||||
|
||||
out = run("update_account", "--no-locked")
|
||||
assert out == "✓ Account updated"
|
||||
|
||||
account = api.verify_credentials(app, user)
|
||||
account = api.verify_credentials(app, user).json()
|
||||
assert account["locked"] is False
|
||||
|
||||
|
||||
@ -83,13 +83,13 @@ def test_update_account_bot(run, app, user):
|
||||
out = run("update_account", "--bot")
|
||||
assert out == "✓ Account updated"
|
||||
|
||||
account = api.verify_credentials(app, user)
|
||||
account = api.verify_credentials(app, user).json()
|
||||
assert account["bot"] is True
|
||||
|
||||
out = run("update_account", "--no-bot")
|
||||
assert out == "✓ Account updated"
|
||||
|
||||
account = api.verify_credentials(app, user)
|
||||
account = api.verify_credentials(app, user).json()
|
||||
assert account["bot"] is False
|
||||
|
||||
|
||||
@ -97,13 +97,13 @@ def test_update_account_discoverable(run, app, user):
|
||||
out = run("update_account", "--discoverable")
|
||||
assert out == "✓ Account updated"
|
||||
|
||||
account = api.verify_credentials(app, user)
|
||||
account = api.verify_credentials(app, user).json()
|
||||
assert account["discoverable"] is True
|
||||
|
||||
out = run("update_account", "--no-discoverable")
|
||||
assert out == "✓ Account updated"
|
||||
|
||||
account = api.verify_credentials(app, user)
|
||||
account = api.verify_credentials(app, user).json()
|
||||
assert account["discoverable"] is False
|
||||
|
||||
|
||||
@ -111,11 +111,11 @@ def test_update_account_sensitive(run, app, user):
|
||||
out = run("update_account", "--sensitive")
|
||||
assert out == "✓ Account updated"
|
||||
|
||||
account = api.verify_credentials(app, user)
|
||||
account = api.verify_credentials(app, user).json()
|
||||
assert account["source"]["sensitive"] is True
|
||||
|
||||
out = run("update_account", "--no-sensitive")
|
||||
assert out == "✓ Account updated"
|
||||
|
||||
account = api.verify_credentials(app, user)
|
||||
account = api.verify_credentials(app, user).json()
|
||||
assert account["source"]["sensitive"] is False
|
||||
|
@ -36,25 +36,3 @@ def test_create_app_registered(monkeypatch):
|
||||
|
||||
app = auth.create_app_interactive("bezdomni.net")
|
||||
assert app == 'registered app'
|
||||
|
||||
|
||||
def test_create_user(monkeypatch):
|
||||
app = App(4, 5, 6, 7)
|
||||
|
||||
def assert_user(user, activate=True):
|
||||
assert activate
|
||||
assert isinstance(user, User)
|
||||
assert user.instance == app.instance
|
||||
assert user.username == "foo"
|
||||
assert user.access_token == "abc"
|
||||
|
||||
monkeypatch.setattr(config, 'save_user', assert_user)
|
||||
monkeypatch.setattr(api, 'verify_credentials', lambda x, y: {"username": "foo"})
|
||||
|
||||
user = auth.create_user(app, 'abc')
|
||||
|
||||
assert_user(user)
|
||||
|
||||
#
|
||||
# TODO: figure out how to mock input so the rest can be tested
|
||||
#
|
||||
|
@ -1,8 +1,9 @@
|
||||
import mimetypes
|
||||
from os import path
|
||||
import re
|
||||
import uuid
|
||||
|
||||
from os import path
|
||||
from requests import Response
|
||||
from typing import BinaryIO, List, Optional
|
||||
from urllib.parse import urlparse, urlencode, quote
|
||||
|
||||
@ -537,8 +538,8 @@ def blocked(app, user):
|
||||
return _get_response_list(app, user, "/api/v1/blocks")
|
||||
|
||||
|
||||
def verify_credentials(app, user):
|
||||
return http.get(app, user, '/api/v1/accounts/verify_credentials').json()
|
||||
def verify_credentials(app, user) -> Response:
|
||||
return http.get(app, user, '/api/v1/accounts/verify_credentials')
|
||||
|
||||
|
||||
def single_status(app, user, status_id):
|
||||
|
@ -66,7 +66,7 @@ def get_instance_domain(base_url):
|
||||
def create_user(app, access_token):
|
||||
# Username is not yet known at this point, so fetch it from Mastodon
|
||||
user = User(app.instance, None, access_token)
|
||||
creds = api.verify_credentials(app, user)
|
||||
creds = api.verify_credentials(app, user).json()
|
||||
|
||||
user = User(app.instance, creds['username'], access_token)
|
||||
config.save_user(user, activate=True)
|
||||
|
@ -516,7 +516,7 @@ def blocked(app, user, args):
|
||||
|
||||
|
||||
def whoami(app, user, args):
|
||||
account = api.verify_credentials(app, user)
|
||||
account = api.verify_credentials(app, user).json()
|
||||
print_account(account)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user