diff --git a/funkwhale_network/cli.py b/funkwhale_network/cli.py index 68a631f930d991db05f56fff7926e117d149fe33..dbf0c570beb200f4bcfdb55d7c91b53405173e6e 100644 --- a/funkwhale_network/cli.py +++ b/funkwhale_network/cli.py @@ -305,15 +305,15 @@ def aggregate_crawl_results(domains_info): @click.option("-v", "--verbose", is_flag=True) @click.option("--check", is_flag=True) def start(*, check, verbose): - #worker = arq.worker.import_string("funkwhale_network.worker", "Worker") - #logging.config.dictConfig(worker.logging_config(verbose)) + # worker = arq.worker.import_string("funkwhale_network.worker", "Worker") + # logging.config.dictConfig(worker.logging_config(verbose)) if check: pass - #exit(worker.check_health()) + # exit(worker.check_health()) else: pass - #arq.RunWorkerProcess("funkwhale_network.worker", "Worker", burst=False) + # arq.RunWorkerProcess("funkwhale_network.worker", "Worker", burst=False) def main(): diff --git a/funkwhale_network/routes.py b/funkwhale_network/routes.py index bd26f69456e94ed892c30e08f92ebda3dcf11541..5226cc98cccc2dcdb82aad24abbf6b8fe1ec6f28 100644 --- a/funkwhale_network/routes.py +++ b/funkwhale_network/routes.py @@ -26,7 +26,7 @@ domain_filters = { def validate_domain(raw): - raw = raw.split('://')[-1] + raw = raw.split("://")[-1] if not raw: raise ValueError() diff --git a/funkwhale_network/worker.py b/funkwhale_network/worker.py index bc3a5e045bc36b29688737038b1a5889091e46b7..8a2cace5b9d653c7745ca058d9ae053963a6afde 100644 --- a/funkwhale_network/worker.py +++ b/funkwhale_network/worker.py @@ -9,20 +9,20 @@ from arq import cron async def poll(ctx, domain): - session: ClientSession = ctx['session'] + session: ClientSession = ctx["session"] pool = await db.get_pool(settings.DB_DSN) async with pool as conn: return await crawler.check(conn=conn, session=session, domain=domain) + async def update_all(ctx): pool = await db.get_pool(settings.DB_DSN) for check in await db.get_latest_check_by_domain(pool): await poll(ctx, check["domain"]) - + + class WorkerSettings: - cron_jobs = [ - cron(update_all, minute=None) - ] + cron_jobs = [cron(update_all, minute=None)] max_concurrent_tasks = 20 shutdown_delay = 5 timeout_seconds = 15 diff --git a/tests/test_routes.py b/tests/test_routes.py index 0d8103edaa015c26fbb310265cf1f80da4e0c190..a1a9cb796db749c9eb7afef16949ab84e7d09ca7 100644 --- a/tests/test_routes.py +++ b/tests/test_routes.py @@ -132,10 +132,13 @@ async def test_domains_rss(db_conn, factories, client, mocker): assert resp.headers["content-type"] == "application/rss+xml" -@pytest.mark.parametrize('input,expected', [ - ('example.com', 'example.com'), - ('http://example.com', 'example.com'), - ('https://example.com', 'example.com'), -]) +@pytest.mark.parametrize( + "input,expected", + [ + ("example.com", "example.com"), + ("http://example.com", "example.com"), + ("https://example.com", "example.com"), + ], +) def test_validate_domain(input, expected): assert routes.validate_domain(input) == expected