fediverse_pasture.runner
ActivityRunner
dataclass
Coordinates sending an activity to many applications through an ActivitySender instances
Parameters:
Name | Type | Description | Default |
---|---|---|---|
activity_sender
|
ActivitySender
|
an activity sender |
required |
applications
|
List[ApplicationAdapterForLastActivity]
|
list of applications to run against |
required |
wait_time
|
float
|
Time in seconds between trying to fetch the activity from remote servers |
0.5
|
tries
|
int
|
Number of tries to fetch activity from remote servers |
20
|
skip_fetch
|
bool
|
Skips fetching the result |
False
|
Source code in fediverse_pasture/runner/__init__.py
run_for_modifier(modifier)
async
modifier has the same format as for ActivitySender
Parameters:
Name | Type | Description | Default |
---|---|---|---|
modifier
|
Callable[[dict], dict]
|
modifies the base object being send |
required |
Source code in fediverse_pasture/runner/__init__.py
ActivitySender
dataclass
The ActivitySender class serves as a way to coordinate the process of sending the same activity to multiple Fediverse applications.
The basic process is
- Create an Activity with a published timestamp stored in published
- Send this activity to applications using
send
- Retrieve the result from said applications
The usual way to create an ActivitySender is the for_actor
method,
i.e.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
activity_factory
|
ActivityFactory
|
|
required |
object_factory
|
ObjectFactory
|
|
required |
bovine_actor
|
BovineActor
|
|
required |
make_id
|
Callable
|
|
required |
published
|
datetime | None
|
|
None
|
note
|
dict | None
|
|
None
|
activity
|
dict | None
|
|
None
|
object_id
|
str | None
|
|
None
|
sleep_after_getting_inbox
|
bool
|
|
True
|
include_mention
|
bool
|
Set to True if the created Note should mention the target |
False
|
replace_https_with_http
|
bool
|
Replaces ‘https://’ with ‘http://’ in the actor URI and the resolved inbox. Useful to handle applications not supporting a configuration value dedicated to handling the http based Fediverse. |
False
|
public_value
|
str
|
The default value to use for public, see https://codeberg.org/funfedidev/python_fediverse_pasture/issues/41 |
'https://www.w3.org/ns/activitystreams#Public'
|
Source code in fediverse_pasture/runner/__init__.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
|
for_actor(bovine_actor, actor_object)
staticmethod
Initializes the Activity Sender object for a given BovineActor and the corresponding actor object
Source code in fediverse_pasture/runner/__init__.py
init_create_note(modifier)
Sets activity to a Create for a Note. Here the Note is
constructed from a skeleton by applying modifier
to it.
To successfully send the note to most applications, modifier
should set the Note’s content, i.e.
>>> from bovine.testing import actor
>>> from unittest.mock import AsyncMock, Mock
>>> actor_mock = Mock(id=actor["id"])
>>> actor_mock.build.return_value = actor
>>> sender = ActivitySender.for_actor(AsyncMock(), actor_mock)
>>> sender.init_create_note(lambda x: {**x, "content": "text"})
>>> sender.note
{'type': 'Note',
'attributedTo': 'http://actor.example',
'to': ['https://www.w3.org/ns/activitystreams#Public'],
'id': 'http://actor.example/object/...
'published': '...
'content': 'text'}
This method can be used to create objects of other types by overriding “type”.
Source code in fediverse_pasture/runner/__init__.py
send(remote)
async
Sends the activity to the remote user
Parameters:
Name | Type | Description | Default |
---|---|---|---|
remote
|
str
|
Actor URI of the remote user |
required |
Source code in fediverse_pasture/runner/__init__.py
application
app_name_to_coroutine = {None: mastodon_likes, 'bovine': activity_for_bovine_provider('bovine', 'vanilla', 'z3u2Yxcowsarethebestcowsarethebestcowsarethebest'), 'misskey': activity_for_misskey_provider('misskey', 'kitty'), 'mitra': mitra_app, 'firefish': firefish_app, 'hubzilla': hubzilla_app, 'sharkey': activity_for_mastodon_provider('sharkey', 'willy', 'token', determine_actor_uri=True, application_name='sharkey'), 'custom': custom_app}
module-attribute
Used to lookup the coroutine to get the application object
activity_for_firefish(domain, username, session)
async
Creates a ApplicationAdapterForLastActivity object for connecting to firefish. Example usage:
Source code in fediverse_pasture/runner/application/__init__.py
activity_for_mastodon(domain, username, access_token, session, application_name='mastodon', determine_actor_uri=False)
async
Creates a ApplicationAdapterForLastActivity object for connecting to mastodon. Example usage:
Source code in fediverse_pasture/runner/application/__init__.py
actor_for_application(account_uri, application_name, session)
async
Creates a ApplicationAdapterForActor
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_uri
|
str
|
The acct uri, e.g. |
required |
application_name
|
str
|
The name of the application |
required |
session
|
ClientSession
|
the aiohttp ClientSession |
required |
Source code in fediverse_pasture/runner/application/__init__.py
bovine
BovineApplication
dataclass
BovineApplication(domain: str, username: str, secret: str, actor_uri: str | None = None, client: bovine.BovineClient | None = None)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
domain
|
str
|
|
required |
username
|
str
|
|
required |
secret
|
str
|
|
required |
actor_uri
|
str | None
|
|
None
|
client
|
BovineClient | None
|
|
None
|
Source code in fediverse_pasture/runner/application/bovine.py
firefish
FirefishApplication
dataclass
Used to query a firefish application
Parameters:
Name | Type | Description | Default |
---|---|---|---|
domain
|
str
|
|
required |
username
|
str
|
|
required |
session
|
ClientSession | None
|
|
None
|
token
|
str
|
|
'VvGrKxhpIzJ1PomJFTBObYWOELgGniVi'
|
firefish_id
|
str | None
|
|
None
|
Source code in fediverse_pasture/runner/application/firefish.py
determine_actor_firefish_id()
async
Determines the firefish id for the user on the one_actor server, i.e. the one with hostname `pasture_one_actor
Source code in fediverse_pasture/runner/application/firefish.py
mastodon
MastodonApplication
dataclass
MastodonApplication(domain: str, access_token: str, username: str, client: bovine.clients.bearer.BearerAuthClient | None = None, actor_uri: str | None = None)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
domain
|
str
|
|
required |
access_token
|
str
|
|
required |
username
|
str
|
|
required |
client
|
BearerAuthClient | None
|
|
None
|
actor_uri
|
str | None
|
|
None
|
Source code in fediverse_pasture/runner/application/mastodon.py
misskey
MisskeyApplication
dataclass
Used to query a misskey application
Parameters:
Name | Type | Description | Default |
---|---|---|---|
domain
|
str
|
|
required |
username
|
str
|
|
required |
session
|
ClientSession | None
|
|
None
|
misskey_id
|
str | None
|
|
None
|
Source code in fediverse_pasture/runner/application/misskey.py
entry
Entry
dataclass
Represents an entry to generate support tables from.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
entry
|
Dict[str, Dict]
|
Dictionary indexed by application with values the result |
required |
Source code in fediverse_pasture/runner/entry.py
applications
property
Returns the set of application names
apply_to(application, function)
Applies the function to the entry for the given application.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
application
|
str
|
The application name |
required |
function
|
Callable[[Dict], List[str]]
|
extractor for the desired data |
required |
Source code in fediverse_pasture/runner/entry.py
as_grid(apps)
Renders the data for each application as a grid.
If no data is present “no result” is shown.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
apps
|
List[str]
|
List of applications to display |
required |
Source code in fediverse_pasture/runner/entry.py
as_tabs(apps)
Renders the data for each application as tabbed markdown.
If no data is present “no result” is shown.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
apps
|
List[str]
|
List of applications to display |
required |
Source code in fediverse_pasture/runner/entry.py
result_store
ResultStore
Source code in fediverse_pasture/runner/result_store.py
add_result(test_name, application_name, data)
async
Adds a result to the database. The pairs (test_name, application_name) are assumed to be unique. If data already exists, it is overwritten with the new data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
test_name
|
str
|
Name of the test |
required |
application_name
|
str
|
Name of the application |
required |
data
|
dict
|
Data to add |
required |
Source code in fediverse_pasture/runner/result_store.py
delete_record(test_name, application_name)
async
Deletes database record if exists
Parameters:
Name | Type | Description | Default |
---|---|---|---|
test_name
|
str
|
Name of the test |
required |
application_name
|
str
|
Application to delete the result for |
required |
Source code in fediverse_pasture/runner/result_store.py
entry_for_test(test_name)
async
Returns an Entry for test_name. We note here that an Entry contains the results for each application the test result is available for.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
test_name
|
str
|
name of the test entry |
required |
Returns:
Type | Description |
---|---|
Entry
|
Entry from record |
Source code in fediverse_pasture/runner/result_store.py
load(filename='test_results.toml')
async
Deletes the current content from the database, then loads the content from filename to it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename
|
str
|
filename to load from |
'test_results.toml'
|
Source code in fediverse_pasture/runner/result_store.py
results_for_test(test_name)
async
Retrieves the results for a given test_name
Source code in fediverse_pasture/runner/result_store.py
save(filename='test_results.toml')
async
Saves the content of the database to the file given by filename
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename
|
str
|
filename to save to |
'test_results.toml'
|
Source code in fediverse_pasture/runner/result_store.py
with_store(db_url='sqlite://test_results.sqlite')
async
Initializes the database and returns a ResultStore. Usage:
Parameters:
Name | Type | Description | Default |
---|---|---|---|
db_url
|
str
|
Database url string |
'sqlite://test_results.sqlite'
|
Source code in fediverse_pasture/runner/result_store.py
verify_actor
VerifyActorRunner
dataclass
Class to run query the verify runner application for various applications
Parameters:
Name | Type | Description | Default |
---|---|---|---|
application
|
ApplicationAdapterForActor
|
|
required |
verify_actor_url
|
str
|
|
'http://pasture_verify_actor/'
|
session
|
ClientSession | None
|
|
None
|
Source code in fediverse_pasture/runner/verify_actor.py
run()
async
Runs the query. Returns a list containing the results for each application
Source code in fediverse_pasture/runner/verify_actor.py
format_verify_actor_result(result, prefix='###')
Routine to convert the obtained result into a markdown string