Skip to content

Add FileSystemMessagingIntegration and related tests #1904

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 5, 2025

Conversation

MikaKerman
Copy link
Contributor

@MikaKerman MikaKerman commented May 5, 2025

  • Implemented FileSystemMessagingIntegration for sending messages to files.
  • Added unit tests for message sending, file creation, and handling of the create_if_missing flag.
  • Updated messaging integrations init.py to include the new integration.

- Implemented FileSystemMessagingIntegration for sending messages to files.
- Added unit tests for message sending, file creation, and handling of the create_if_missing flag.
- Updated messaging integrations __init__.py to include the new integration.
Copy link

linear bot commented May 5, 2025

@MikaKerman MikaKerman had a problem deploying to elementary_test_env May 5, 2025 09:45 — with GitHub Actions Error
Copy link
Contributor

github-actions bot commented May 5, 2025

👋 @MikaKerman
Thank you for raising your pull request.
Please make sure to add tests and document all user-facing changes.
You can do this by editing the docs files in this pull request.

try:
logger.info("Writing alert message to file %s", file_path)
with open(file_path, "a", encoding="utf-8") as fp:
fp.write(body.json())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add indent to the json, will make it much easier to debug

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

if not os.path.exists(self.directory):
if self._create_if_missing:
logger.info(
"Creating directory for FileSystemMessagingIntegration: %s",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not direct formating? f"Creating directory for FileSystemMessagingIntegration: {self.directory}"
(relevant to all of the logs)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

BaseMessagingIntegration[str, EmptyMessageContext]
):
def __init__(self, directory: str, create_if_missing: bool = True) -> None:
self.directory = os.path.abspath(directory)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd much prefer usage pathlib.Path instead of os.path, much cleaner and more modern

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

…ngs and update tests to match new channel-directory JSON file behavior
@MikaKerman MikaKerman had a problem deploying to elementary_test_env May 5, 2025 11:49 — with GitHub Actions Error
@MikaKerman MikaKerman temporarily deployed to elementary_test_env May 5, 2025 12:21 — with GitHub Actions Inactive
@MikaKerman MikaKerman merged commit d71d811 into master May 5, 2025
4 checks passed
@MikaKerman MikaKerman deleted the ele-4367-file-system-messaging-integration branch May 5, 2025 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants