From 2ddafc790fd50832fc2974e8319b56cc870a36a3 Mon Sep 17 00:00:00 2001 From: Dennis Iversen Date: Fri, 10 Jan 2025 15:00:32 +0100 Subject: [PATCH] clean up code. --- .flake8 | 3 +- bin/post_webhook.py | 2 +- pyproject.toml | 2 +- .../endpoints/endpoints_order.py | 1 - stadsarkiv_client/endpoints/endpoints_test.py | 21 ++++++----- .../endpoints/endpoints_webhooks.py | 35 +------------------ 6 files changed, 15 insertions(+), 49 deletions(-) diff --git a/.flake8 b/.flake8 index 4f5a92c3..170284b7 100644 --- a/.flake8 +++ b/.flake8 @@ -1,6 +1,7 @@ [flake8] exclude = .git, __pycache__, .mypy_cache, .pytest_cache, venv, .github, \ stadsarkiv_client/templates,stadsarkiv_client/locales, generate_client, tests, \ - example-config-aarhus, example-config-simple, example-config-teater, build + example-config-aarhus, example-config-simple, example-config-teater, build, \ + bin-local ignore = E203, W503, E402, E231 max-line-length = 140 diff --git a/bin/post_webhook.py b/bin/post_webhook.py index 7368493e..b748ec07 100644 --- a/bin/post_webhook.py +++ b/bin/post_webhook.py @@ -23,4 +23,4 @@ async def verify_token(token): print(f"An error occurred: {error}") -asyncio.run(verify_token("some-test-token")) \ No newline at end of file +asyncio.run(verify_token("some-test-token")) diff --git a/pyproject.toml b/pyproject.toml index 7b4f546a..af96b877 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,7 @@ line-length = 140 [tool.mypy] -exclude = [ "venv", ".venv", "generate_openaws_client", "tests", "example-config", "build",] +exclude = [ "venv", ".venv", "generate_openaws_client", "tests", "example-config", "build", "bin-local",] [tool.bump_version] version_file = "stadsarkiv_client/__init__.py" diff --git a/stadsarkiv_client/endpoints/endpoints_order.py b/stadsarkiv_client/endpoints/endpoints_order.py index 037c84d4..ac6c0cc7 100644 --- a/stadsarkiv_client/endpoints/endpoints_order.py +++ b/stadsarkiv_client/endpoints/endpoints_order.py @@ -8,7 +8,6 @@ from stadsarkiv_client.records.meta_data_record import get_record_meta_data from stadsarkiv_client.core.hooks import get_hooks from stadsarkiv_client.core.logging import get_log -from stadsarkiv_client.core.flash import set_message from stadsarkiv_client.database import crud_orders from stadsarkiv_client.database import utils_orders from stadsarkiv_client.core import flash diff --git a/stadsarkiv_client/endpoints/endpoints_test.py b/stadsarkiv_client/endpoints/endpoints_test.py index 228d8531..3946144f 100644 --- a/stadsarkiv_client/endpoints/endpoints_test.py +++ b/stadsarkiv_client/endpoints/endpoints_test.py @@ -11,7 +11,6 @@ from stadsarkiv_client.database.cache import DatabaseCache from stadsarkiv_client.database.crud_default import database_url from stadsarkiv_client.database.utils import DatabaseConnection -from stadsarkiv_client.core import api from stadsarkiv_client.core.dynamic_settings import settings import random @@ -83,16 +82,16 @@ async def test_mail(request: Request): # template_str = await get_template_content("mails/verify_email.html", context) - data_dict = { - "data": { - "user_id": "01944542-2d7b-72bc-82bf-34e735b383cb", - "subject": "Test", - "sender": {"email": "stadsarkivet@aarhusarkivet.dk", "name": "Aarhus Stadsarkiv"}, - "reply_to": {"email": "stadsarkivet@aarhusarkivet.dk", "name": "Aarhus Stadsarkiv"}, - "html_content": "Test Test", - "text_content": "Test Test", - } - } + # data_dict = { + # "data": { + # "user_id": "01944542-2d7b-72bc-82bf-34e735b383cb", + # "subject": "Test", + # "sender": {"email": "stadsarkivet@aarhusarkivet.dk", "name": "Aarhus Stadsarkiv"}, + # "reply_to": {"email": "stadsarkivet@aarhusarkivet.dk", "name": "Aarhus Stadsarkiv"}, + # "html_content": "Test Test", + # "text_content": "Test Test", + # } + # } # await api.mail_post(request, data_dict) diff --git a/stadsarkiv_client/endpoints/endpoints_webhooks.py b/stadsarkiv_client/endpoints/endpoints_webhooks.py index eec0e896..e1417ba5 100644 --- a/stadsarkiv_client/endpoints/endpoints_webhooks.py +++ b/stadsarkiv_client/endpoints/endpoints_webhooks.py @@ -2,7 +2,7 @@ Webhook endpoints """ -from starlette.responses import JSONResponse, HTMLResponse +from starlette.responses import JSONResponse from starlette.requests import Request from stadsarkiv_client.core.logging import get_log from stadsarkiv_client.core.mail import get_template_content @@ -116,36 +116,3 @@ async def mail_reset_token(request: Request): log.exception("Error in sending reset email to user") return JSONResponse({"status": "ok", "data": data}) - - -""" - -# Test data. This ID will not work if sending to the real API - - data: dict = { - "nonce": "ya_X5caNnPNNV8I1DRjogmHzO3xoKBn2OffA5M1we4c", - "context": {}, - "original_request_id": "09c74815a76841d98da1268fdcb3b3e6", - "error": None, - "timestamp": 1736240547.001911, - "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIwMTk0NDAwMC00NDlhLTc0M2EtYjU4My0yNDJkMjNjMmNjZjgiLCJlbWFpbCI6IjAxOTQ0MDAwNDQ5NjcxMmVhODhiZmFlZjM2ODQ5MTY5QGludGVybmFsLmxvY2FsIiwiYXVkIjoiZmFzdGFwaS11c2Vyczp2ZXJpZnkiLCJleHAiOjE3MzYyNDQxNDZ9.dFuissS8vA7ZESmwPvH-aQy_Hn5zsY0Z4SJUhom9iY0", - "to_user": { - "id": "019265e5-3fd4-7734-990c-7c7660d1ca64", - "email": "dennis.iversen+x@gmail.com", - "is_active": True, - "is_verified": False, - "client_id": "demo", - "display_name": "diversen", - "data": {"bookmarks": [], "custom": {"updated": 1736240547, "data": {}}}, - "timestamp": 1736240546, - "updated": 1736240546, - "last_login": 1736240546, - "permissions": [ - {"name": "user", "grant_id": 6, "entity_id": None}, - {"name": "guest", "grant_id": 8, "entity_id": None}, - {"name": "read", "grant_id": 9, "entity_id": None}, - ], - }, - } - -"""