Skip to content

Commit

Permalink
Some minor cleanup (#384)
Browse files Browse the repository at this point in the history
* ParsedUri should have a get_scheme() method
* Fix WordPress app name
* Better comments
* Add a --domain flag to the run invocations in the Makefile
---------

Co-authored-by: Johannes Ernst <git@j12t.org>
  • Loading branch information
jernst and Johannes Ernst authored Oct 12, 2024
1 parent d96f861 commit 9556b18
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 8 deletions.
10 changes: 6 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ BRANCH?=$(shell git branch --show-current)
VENV?=venv.$(UNAME).$(BRANCH)
PYTHON?=python3.11
FEDITEST?=$(VENV)/bin/feditest -v
DOMAIN?=--domain 1234.lan


default : all

Expand Down Expand Up @@ -50,10 +52,10 @@ tests.unit : venv
$(VENV)/bin/pytest -v

tests.smoke : venv
$(FEDITEST) run --testsdir tests.smoke/tests --session tests.smoke/mastodon_api.session.json --constellation tests.smoke/mastodon.ubos.constellation.json
$(FEDITEST) run --testsdir tests.smoke/tests --session tests.smoke/mastodon_api.session.json --constellation tests.smoke/wordpress.ubos.constellation.json
$(FEDITEST) run --testsdir tests.smoke/tests --session tests.smoke/mastodon_api_mastodon_api.session.json --constellation tests.smoke/mastodon_mastodon.ubos.constellation.json
# Currently broken: $(FEDITEST) run --testsdir tests.smoke/tests --session tests.smoke/mastodon_api_mastodon_api.session.json --constellation tests.smoke/wordpress_mastodon.ubos.constellation.json
$(FEDITEST) run --testsdir tests.smoke/tests --session tests.smoke/mastodon_api.session.json --constellation tests.smoke/mastodon.ubos.constellation.json $(DOMAIN)
$(FEDITEST) run --testsdir tests.smoke/tests --session tests.smoke/mastodon_api.session.json --constellation tests.smoke/wordpress.ubos.constellation.json $(DOMAIN)
$(FEDITEST) run --testsdir tests.smoke/tests --session tests.smoke/mastodon_api_mastodon_api.session.json --constellation tests.smoke/mastodon_mastodon.ubos.constellation.json $(DOMAIN)
# Currently broken: $(FEDITEST) run --testsdir tests.smoke/tests --session tests.smoke/mastodon_api_mastodon_api.session.json --constellation tests.smoke/wordpress_mastodon.ubos.constellation.json $(DOMAIN)

release :
@which $(PYTHON) || ( echo 'No executable called "python". Append your python to the make command, like "make PYTHON=your-python"' && false )
Expand Down
4 changes: 2 additions & 2 deletions src/feditest/nodedrivers/wordpress/ubos.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def set_node(self, node: Node) -> None:

class WordPressPlusPluginsUbosNode(WordPressPlusPluginsNode):
"""
A WordPress + ActivityPubPlugin Node running on UBOS. This means we know how to interact with it exactly.
A WordPress + plugins Node running on UBOS. This means we know how to interact with it exactly.
"""
# Python 3.12 @override
def provision_account_for_role(self, role: str | None = None) -> Account | None:
Expand Down Expand Up @@ -163,7 +163,7 @@ def create_configuration_account_manager(self, rolename: str, test_plan_node: Te
}
},
defaults = {
'app' : 'WordPress + ActivityPub plugin'
'app' : 'WordPress + plugins'
}),
WordPressUbosAccountManager(accounts, non_existing_accounts)
)
Expand Down
2 changes: 1 addition & 1 deletion src/feditest/protocols/activitypub/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class ActivityPubNode(WebServer):
"""
def obtain_actor_document_uri(self, rolename: str | None = None) -> str:
"""
Smart factory method to return the URI to an Actor document on this Node that
Smart factory method to return the https URI to an Actor document on this Node that
either exists already or is newly created. Different rolenames produce different
results; the same rolename produces the same result.
rolename: refer to this Actor by this rolename; used to disambiguate multiple
Expand Down
2 changes: 1 addition & 1 deletion src/feditest/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def obtain_new_hostname(self, appname: str | None = None) -> str:
if not appname:
safe_appname = 'unnamed'
elif m := re.match('^([0-9A-Za-z]*)', appname):
safe_appname = m.group(1).lower()
safe_appname = m.group(1).lower() # take the first word
else:
safe_appname = 'other'

Expand Down
27 changes: 27 additions & 0 deletions src/feditest/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ def parse(url: str, scheme='', allow_fragments=True) -> Optional['ParsedUri']:
return ParsedNonAcctUri(parsed.scheme, parsed.netloc, parsed.path, parsed.params, parsed.query, parsed.fragment)


@abstractmethod
def get_scheme(self) -> str:
...


@abstractmethod
def get_uri(self) -> str:
...
Expand All @@ -71,6 +76,12 @@ def __init__(self, scheme: str, netloc: str, path: str, params: str, query: str,
self._query_params : dict[str,list[str]] | None = None


# Python 3.12 @override
def get_scheme(self) -> str:
return self.scheme


# Python 3.12 @override
def get_uri(self) -> str:
ret = f'{ self.scheme }:'
if self.netloc:
Expand Down Expand Up @@ -112,6 +123,7 @@ def query_param_mult(self, name: str) -> List[str] | None:
return None


# Python 3.12 @override
def __repr__(self):
return f'ParsedNonAcctUri({ self.get_uri() })'

Expand All @@ -134,10 +146,25 @@ def __init__(self, user: str, host: str):
self.host = host


# Python 3.12 @override
def get_scheme(self) -> str:
return 'acct'


def get_user(self) -> str:
return self.user


def get_host(self) -> str:
return self.host


# Python 3.12 @override
def get_uri(self) -> str:
return f'acct:{ self.user }@{ self.host }'


# Python 3.12 @override
def __repr__(self):
return f'ParsedAcctUri({ self.get_uri() })'

Expand Down

0 comments on commit 9556b18

Please sign in to comment.