Porównaj commity

...

11 Commity

Autor SHA1 Wiadomość Data
Daniel Schwarz 3f74b0a004
Merge 31bbb20324 into 5cd25e2ce2 2024-04-22 12:36:00 +02:00
Ivan Habunek 5cd25e2ce2
Tweak pyright config 2024-04-20 13:36:35 +02:00
Ivan Habunek aa1f2a5bc8
Start documenting testing 2024-04-20 13:27:42 +02:00
Daniel Schwarz 31bbb20324 Make this fix compatible with latest master 2024-03-05 20:08:54 -05:00
Daniel Schwarz 9d59df6c7e Merge branch 'master' into asyncfix 2024-03-05 20:03:05 -05:00
Daniel Schwarz d21b2920cb Fix for compatibility with more recent versions of toot 2024-03-05 19:58:54 -05:00
Daniel Schwarz a5cd9d343c Merge branch 'asyncfix' of https://github.com/danschwarz/toot into asyncfix 2024-03-05 19:58:18 -05:00
Daniel Schwarz c30657dc24
Merge branch 'ihabunek:master' into asyncfix 2023-01-30 13:42:43 -05:00
Daniel Schwarz cb7cbd872a
Merge branch 'ihabunek:master' into asyncfix 2023-01-30 09:16:19 -05:00
Daniel Schwarz ecb9c75f2e React properly to 422: Validation Failed. Status has already been taken errors 2022-12-31 18:16:51 -05:00
Daniel Schwarz fe5b9d1a46 React properly to 422: Validation Failed. Status has already been taken errors 2022-12-13 12:45:07 -05:00
3 zmienionych plików z 89 dodań i 12 usunięć

56
docs/testing.md 100644
Wyświetl plik

@ -0,0 +1,56 @@
# Running toot tests
## Mastodon
Clone mastodon repo and check out the tag you want to test:
```
git clone https://github.com/mastodon/mastodon
cd mastodon
git checkout v4.2.8
```
Set up the required Ruby version using [ASDF](https://asdf-vm.com/). The
required version is listed in `.ruby-version`.
```
asdf install ruby 3.2.3
asdf local ruby 3.2.3
```
Install and set up database:
```
bundle install
yarn install
rails db:setup
```
Patch code so users are auto-approved:
```
curl https://paste.sr.ht/blob/7c6e08bbacf3da05366b3496b3f24dd03d60bd6d | git am
```
Open registrations:
```
bin/tootctl settings registration open
```
Install foreman to run the thing:
```
gem install foreman
```
Start the server:
```
foreman start
```
## Pleroma
https://docs-develop.pleroma.social/backend/development/setting_up_pleroma_dev/

Wyświetl plik

@ -81,6 +81,5 @@ packages=[
[tool.setuptools_scm]
[tool.pyright]
include = ["toot"]
typeCheckingMode = "strict"
pythonVersion = "3.8"

Wyświetl plik

@ -8,7 +8,7 @@ from typing import BinaryIO, List, Optional
from urllib.parse import urlparse, urlencode, quote
from toot import App, User, http, CLIENT_NAME, CLIENT_WEBSITE
from toot.exceptions import ConsoleError
from toot.exceptions import ApiError, ConsoleError
from toot.utils import drop_empty_values, str_bool, str_bool_nullable
@ -53,8 +53,28 @@ def _tag_action(app, user, tag_name, action) -> Response:
return http.post(app, user, url)
def create_app(base_url):
url = f"{base_url}/api/v1/apps"
def _status_toggle_action(app, user, status_id, action, data=None):
url = '/api/v1/statuses/{}/{}'.format(status_id, action)
try:
response = http.post(app, user, url).json()
except ApiError as e:
# For "toggle" operations, Mastodon returns unhelpful
# 422: "Validation failed: Status has already been taken"
# responses when you try to bookmark a status already
# bookmarked, or favourite a status already favourited
# so we just swallow those errors here
if str(e) == "Validation failed: Status has already been taken":
response = None
else:
# not the error we expected; re-raise the exception
raise e
finally:
return response
def create_app(domain, scheme='https'):
url = f"{scheme}://{domain}/api/v1/apps"
json = {
'client_name': CLIENT_NAME,
@ -310,38 +330,40 @@ def delete_status(app, user, status_id):
def favourite(app, user, status_id):
return _status_action(app, user, status_id, 'favourite')
return _status_toggle_action(app, user, status_id, 'favourite')
def unfavourite(app, user, status_id):
return _status_action(app, user, status_id, 'unfavourite')
return _status_toggle_action(app, user, status_id, 'unfavourite')
def reblog(app, user, status_id, visibility="public"):
return _status_action(app, user, status_id, 'reblog', data={"visibility": visibility})
return _status_toggle_action(app, user, status_id, 'reblog', data={"visibility": visibility})
def unreblog(app, user, status_id):
return _status_action(app, user, status_id, 'unreblog')
return _status_toggle_action(app, user, status_id, 'unreblog')
def pin(app, user, status_id):
return _status_action(app, user, status_id, 'pin')
return _status_toggle_action(app, user, status_id, 'pin')
def unpin(app, user, status_id):
return _status_action(app, user, status_id, 'unpin')
return _status_toggle_action(app, user, status_id, 'unpin')
def bookmark(app, user, status_id):
return _status_action(app, user, status_id, 'bookmark')
return _status_toggle_action(app, user, status_id, 'bookmark')
def unbookmark(app, user, status_id):
return _status_action(app, user, status_id, 'unbookmark')
return _status_toggle_action(app, user, status_id, 'unbookmark')
def translate(app, user, status_id):
# don't use status_toggle_action for translate as this is
# not toggling anything server-side; it's a read only operation.
return _status_action(app, user, status_id, 'translate')