1
0
mirror of https://github.com/ihabunek/toot.git synced 2024-06-16 06:15:25 +00:00

Compare commits

...

2 Commits

Author SHA1 Message Date
Luca Matei Pintilie
1d48e64853
Fix version check in case of an empty string
Some mastodon implementations (GoToSocial) will return `version: ""`, in
which case checking for the major version won't work.

This is why an extra check has to be added, and default to 0 as the
"major" version.
2024-04-06 14:56:54 +02:00
Ivan Habunek
bf12dbff70
Use a stronger password in tests
gotosocial registration fails with a weak password
2024-04-06 13:15:36 +02:00
3 changed files with 8 additions and 4 deletions

View File

@ -41,6 +41,8 @@ TRUMPET = str(Path(__file__).parent.parent.parent / "trumpet.png")
ASSETS_DIR = str(Path(__file__).parent.parent / "assets") ASSETS_DIR = str(Path(__file__).parent.parent / "assets")
PASSWORD = "83dU29170rjKilKQQwuWhJv3PKnSW59bWx0perjP6i7Nu4rkeh4mRfYuvVLYM3fM"
def create_app(base_url): def create_app(base_url):
instance = api.get_instance(base_url).json() instance = api.get_instance(base_url).json()
@ -52,7 +54,7 @@ def register_account(app: App):
username = str(uuid.uuid4())[-10:] username = str(uuid.uuid4())[-10:]
email = f"{username}@example.com" email = f"{username}@example.com"
response = api.register_account(app, username, email, "password", "en") response = api.register_account(app, username, email, PASSWORD, "en")
return User(app.instance, username, response["access_token"]) return User(app.instance, username, response["access_token"])

View File

@ -3,7 +3,7 @@ from unittest import mock
from unittest.mock import MagicMock from unittest.mock import MagicMock
from toot import User, cli from toot import User, cli
from tests.integration.conftest import Run from tests.integration.conftest import PASSWORD, Run
# TODO: figure out how to test login # TODO: figure out how to test login
@ -89,7 +89,7 @@ def test_login_cli(
cli.auth.login_cli, cli.auth.login_cli,
"--instance", "http://localhost:3000", "--instance", "http://localhost:3000",
"--email", f"{user.username}@example.com", "--email", f"{user.username}@example.com",
"--password", "password", "--password", PASSWORD,
) )
assert result.exit_code == 0 assert result.exit_code == 0
assert "✓ Successfully logged in." in result.stdout assert "✓ Successfully logged in." in result.stdout

View File

@ -327,8 +327,10 @@ class TUI(urwid.Frame):
# get the major version number of the server # get the major version number of the server
# this works for Mastodon and Pleroma version strings # this works for Mastodon and Pleroma version strings
# Mastodon versions < 4 do not have translation service # Mastodon versions < 4 do not have translation service
# If the version is missing, assume 0 as a fallback
# Revisit this logic if Pleroma implements translation # Revisit this logic if Pleroma implements translation
ch = instance["version"][0] version = instance["version"]
ch = "0" if not version else version[0]
self.can_translate = int(ch) > 3 if ch.isnumeric() else False self.can_translate = int(ch) > 3 if ch.isnumeric() else False
return self.run_in_thread(_load_instance, done_callback=_done) return self.run_in_thread(_load_instance, done_callback=_done)