From 36b372fb2d4b6c63971afc96fda5ed8c391eba5d Mon Sep 17 00:00:00 2001 From: Jon Michael Aanes Date: Sun, 25 Aug 2024 20:56:47 +0200 Subject: [PATCH] Import fetchers --- personal_data/__main__.py | 4 ++++ personal_data/main.py | 1 + test/test_main.py | 7 +++++++ 3 files changed, 12 insertions(+) create mode 100644 test/test_main.py diff --git a/personal_data/__main__.py b/personal_data/__main__.py index 2edcb50..fa7a3b5 100644 --- a/personal_data/__main__.py +++ b/personal_data/__main__.py @@ -7,6 +7,10 @@ from personal_data.notification import NotificationType def parse_arguments(): available_scraper_names = personal_data.main.available_scraper_names() + if len(available_scraper_names) == 0: + msg = 'Failed to load any scrapers' + raise Exception(msg) + parser = argparse.ArgumentParser( epilog='Available fetchers: ' + ' '.join(available_scraper_names), ) diff --git a/personal_data/main.py b/personal_data/main.py index 795cfa7..f239ffe 100644 --- a/personal_data/main.py +++ b/personal_data/main.py @@ -64,6 +64,7 @@ def get_session( def available_scrapers() -> list[type[data.Scraper]]: + from . import fetchers subclasses = [] class_queue = [data.Scraper] while class_queue: diff --git a/test/test_main.py b/test/test_main.py new file mode 100644 index 0000000..d78e64b --- /dev/null +++ b/test/test_main.py @@ -0,0 +1,7 @@ +import personal_data.main + + +def test_available(): + names = personal_data.main.available_scraper_names() + assert len(names) > 0 +