Skip to content

Commit

Permalink
Fix interactive prompts. (#434)
Browse files Browse the repository at this point in the history
Closes #431
Closes #432

Co-authored-by: Johannes Ernst <[email protected]>
  • Loading branch information
jernst and Johannes Ernst authored Dec 17, 2024
1 parent 056dd08 commit b15aff2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions src/feditest/nodedrivers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,11 +454,11 @@ def provision_non_existing_account_for_role(self, role: str | None = None) -> No


def add_cert_to_trust_store(self, root_cert: str) -> None:
prompt_user(f'Please add this temporary certificate to the trust root of node { self } and hit return when done:\n' + root_cert)
prompt_user(f'Please add this temporary certificate to the trust root of node { self } and hit return when done:\n{ root_cert }\nHit return: ')


def remove_cert_from_trust_store(self, root_cert: str) -> None:
prompt_user(f'Please remove this previously-added temporary certificate from the trust store of node { self } and hit return when done:\n' + root_cert)
prompt_user(f'Please remove this previously-added temporary certificate from the trust store of node { self } and hit return when done:\n{ root_cert }\nHit return: ')


def __str__(self) -> str:
Expand Down
38 changes: 19 additions & 19 deletions src/feditest/nodedrivers/fallback/fediverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,20 @@ def obtain_non_existing_actor_acct_uri(self, rolename: str | None = None ) -> st
def make_follow(self, actor_acct_uri: str, to_follow_actor_acct_uri: str) -> None:
prompt_user(
f'On FediverseNode "{ self.hostname }", make actor "{ actor_acct_uri }" follow actor "{ to_follow_actor_acct_uri }"'
+ ' and hit return when done.')
+ ' and hit return when done: ')


def make_unfollow(self, actor_acct_uri: str, following_actor_acct_uri: str) -> None:
prompt_user(
f'On FediverseNode "{ self.hostname }", make actor "{ actor_acct_uri }" unfollow actor "{ following_actor_acct_uri }"'
+ ' and hit return when done.')
+ ' and hit return when done: ')


# Python 3.12 @override
def actor_is_following_actor(self, actor_acct_uri: str, leader_actor_acct_uri: str) -> bool:
answer = prompt_user_parse_validate(
f'On FediverseNode "{ self.hostname }", is actor "{ actor_acct_uri }" following actor "{ leader_actor_acct_uri }"?'
+ ' Enter "true" or "false".',
+ ' Enter "true" or "false": ',
parse_validate=boolean_parse_validate)
return answer

Expand All @@ -100,7 +100,7 @@ def actor_is_following_actor(self, actor_acct_uri: str, leader_actor_acct_uri: s
def actor_is_followed_by_actor(self, actor_acct_uri: str, follower_actor_acct_uri: str) -> bool:
answer = prompt_user_parse_validate(
f'On FediverseNode "{ self.hostname }", is actor "{ actor_acct_uri }" being followed by actor "{ follower_actor_acct_uri }"?'
+ ' Enter "true" or "false".',
+ ' Enter "true" or "false": ',
parse_validate=boolean_parse_validate)
return answer

Expand All @@ -113,58 +113,58 @@ def make_create_note(self, actor_acct_uri: str, content: str, deliver_to: list[s
f'On FediverseNode "{ self.hostname }", make actor "{ actor_acct_uri }" create a Note'
+ ' to be delivered to ' + ", ".join(deliver_to)
+ ' and enter its URI when created.'
+ f' Note content:"""\n{ content }\n"""',
+ f' Note content (between the quotes):\n"""\n{ content }\n"""\nURI: ',
parse_validate=https_uri_validate)
return prompt_user_parse_validate(
f'On FediverseNode "{ self.hostname }", make actor "{ actor_acct_uri }" create a Note'
+ ' and enter its URI when created.'
+ f' Note content:"""\n{ content }\n"""',
+ f' Note content (between the quotes):\n"""\n{ content }\n"""\nURI: ',
parse_validate=https_uri_validate)


# Python 3.12 @override
def update_note(self, actor_acct_uri: str, note_uri: str, new_content: str) -> None:
prompt_user(
f'On FediverseNode "{ self.hostname }", make actor "{ actor_acct_uri }" update the note at "{ note_uri }"'
+ ' with new content:"""\n{ new_content }\n"""'
+ ' and hit return when done.')
+ ' with new conten (between the quotes):\n"""\n{ new_content }\n"""\n'
+ 'and hit return when done: ')


# Python 3.12 @override
def delete_object(self, actor_acct_uri: str, object_uri: str) -> None:
prompt_user(
f'On FediverseNode "{ self.hostname }", make actor "{ actor_acct_uri }" delete the object at "{ object_uri }"'
+ ' and hit return when done.')
+ ' and hit return when done:')


# Python 3.12 @override
def make_reply_note(self, actor_acct_uri, to_be_replied_to_object_uri: str, reply_content: str) -> str:
return prompt_user_parse_validate(
f'On FediverseNode "{ self.hostname }", make actor "{ actor_acct_uri }" reply to object with "{ to_be_replied_to_object_uri }"'
+ ' and enter the reply note\'s URI when created.'
+ f' Reply content:"""\n{ reply_content }\n"""',
+ f' Reply content (between the quotes):\n"""\n{ reply_content }\n"""\nURI: ',
parse_validate=https_uri_validate)


# Python 3.12 @override
def like_object(self, actor_acct_uri: str, object_uri: str) -> None:
prompt_user(
f'On FediverseNode "{ self.hostname }", make actor "{ actor_acct_uri }" like the object at "{ object_uri }"'
+ ' and hit return when done.')
+ ' and hit return when done: ')


# Python 3.12 @override
def unlike_object(self, actor_acct_uri: str, object_uri: str) -> None:
prompt_user(
f'On FediverseNode "{ self.hostname }", make actor "{ actor_acct_uri }" unlike the object at "{ object_uri }"'
+ ' and hit return when done.')
+ ' and hit return when done: ')


# Python 3.12 @override
def announce_object(self, actor_acct_uri: str, object_uri: str) -> None:
prompt_user(
f'On FediverseNode "{ self.hostname }", make actor "{ actor_acct_uri }" announce/reblog/boost the object at "{ object_uri }"'
+ ' and hit return when done.')
+ ' and hit return when done: ')


# Python 3.12 @override
Expand All @@ -178,21 +178,21 @@ def unannounce_object(self, actor_acct_uri: str, object_uri: str) -> None:
def actor_has_received_object(self, actor_acct_uri: str, object_uri: str) -> str | None:
answer = prompt_user(
f'On FediverseNode "{ self.hostname }", has actor "{ actor_acct_uri }" received the object "{ object_uri }"?'
+ ' Enter the content of the object, or leave empty if it didn\'t happen.')
+ ' Enter the content of the object, or leave empty if it didn\'t happen: ')
return answer if answer else None


# Python 3.12 @override
def note_content(self, actor_acct_uri: str, note_uri: str) -> str | None:
answer = prompt_user(
f'On FediverseNode "{ self.hostname }", have actor "{ actor_acct_uri }" access note "{ note_uri }" and enter its content.')
f'On FediverseNode "{ self.hostname }", have actor "{ actor_acct_uri }" access note "{ note_uri }" and enter its content: ')
return answer if answer else None


# Python 3.12 @override
def object_author(self, actor_acct_uri: str, object_uri: str) -> str | None:
answer = prompt_user_parse_validate(
f'On FediverseNode "{ self.hostname }", have actor "{ actor_acct_uri }" access object "{ object_uri }" and enter the acct URI of the object\'s author.',
f'On FediverseNode "{ self.hostname }", have actor "{ actor_acct_uri }" access object "{ object_uri }" and enter the acct URI of the object\'s author: ',
parse_validate=acct_uri_validate)
return answer

Expand All @@ -201,7 +201,7 @@ def object_author(self, actor_acct_uri: str, object_uri: str) -> str | None:
def direct_replies_to_object(self, actor_acct_uri: str, object_uri: str) -> list[str]:
answer = prompt_user_parse_validate(
f'On FediverseNode "{ self.hostname }", have actor "{ actor_acct_uri }" access object "{ object_uri }"'
+ ' and enter the https URIs of all objects that directly reply to it (space-separated list).',
+ ' and enter the https URIs of all objects that directly reply to it (space-separated list): ',
parse_validate=https_uri_list_validate)
return answer.split()

Expand All @@ -210,7 +210,7 @@ def direct_replies_to_object(self, actor_acct_uri: str, object_uri: str) -> list
def object_likers(self, actor_acct_uri: str, object_uri: str) -> list[str]:
answer = prompt_user_parse_validate(
f'On FediverseNode "{ self.hostname }", have actor "{ actor_acct_uri }" access object "{ object_uri }"'
+ ' and enter the acct URIs of all accounts that like it (space-separated list).',
+ ' and enter the acct URIs of all accounts that like it (space-separated list): ',
parse_validate=acct_uri_list_validate)
return answer.split()

Expand All @@ -219,7 +219,7 @@ def object_likers(self, actor_acct_uri: str, object_uri: str) -> list[str]:
def object_announcers(self, actor_acct_uri: str, object_uri: str) -> list[str]:
answer = prompt_user_parse_validate(
f'On FediverseNode "{ self.hostname }", have actor "{ actor_acct_uri }" access object "{ object_uri }"'
+ ' and enter the acct URIs of all accounts that have announced/reblogged/boosted it (space-separated list).',
+ ' and enter the acct URIs of all accounts that have announced/reblogged/boosted it (space-separated list): ',
parse_validate=acct_uri_list_validate)
return answer.split()

Expand Down
4 changes: 2 additions & 2 deletions src/feditest/nodedrivers/manual/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ class FediverseManualNodeDriver(AbstractFallbackFediverseNodeDriver):
def _provision_node(self, rolename: str, config: NodeConfiguration, account_manager: AccountManager | None) -> FediverseNode:
prompt_user(
f'Manually provision the Node for constellation role { rolename }'
+ f' at host { config.hostname } with app { config.app } and hit return when done.')
+ f' at host { config.hostname } with app { config.app } and hit return when done: ')
return FallbackFediverseNode(rolename, config, account_manager)


# Python 3.12 @override
def _unprovision_node(self, node: Node) -> None:
prompt_user(f'Manually unprovision the Node for constellation role { node.rolename } and hit return when done.')
prompt_user(f'Manually unprovision the Node for constellation role { node.rolename } and hit return when done: ')

0 comments on commit b15aff2

Please sign in to comment.