diff --git a/CHANGELOG.md b/CHANGELOG.md index 74207e49..6650ffe5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.0.1] - 2024-08-25 + +### Fixed + +- [AssertionError from apprise.notify(title=str(title), body=str(body))](https://github.com/klept0/MS-Rewards-Farmer/issues) + ## [1.0.0] - 2024-08-23 ### Removed diff --git a/src/utils.py b/src/utils.py index 51bd614d..5b2fc555 100644 --- a/src/utils.py +++ b/src/utils.py @@ -46,7 +46,11 @@ def loadConfig(configFilename="config.yaml") -> dict: configFile = Utils.getProjectRoot() / configFilename try: with open(configFile, "r") as file: - return yaml.safe_load(file) + config = yaml.safe_load(file) + if not config: + logging.info(f"{file} doesn't exist") + return {} + return config except OSError: logging.warning(f"{configFilename} doesn't exist") return {} @@ -57,6 +61,9 @@ def sendNotification(title, body) -> None: return apprise = Apprise() urls: list[str] = Utils.loadConfig("config-private.yaml").get("apprise", {}).get("urls", []) + if not urls: + logging.debug("No urls found, not sending notification") + return for url in urls: apprise.add(url) assert apprise.notify(title=str(title), body=str(body)) diff --git a/test/test_utils.py b/test/test_utils.py new file mode 100644 index 00000000..780a76e8 --- /dev/null +++ b/test/test_utils.py @@ -0,0 +1,11 @@ +from argparse import Namespace +from unittest import TestCase + +from src.utils import Utils + + +class TestUtils(TestCase): + def test_send_notification(self): + Utils.args = Namespace() + Utils.args.disable_apprise = False + Utils.sendNotification("title", "body")