From ee96104f66d65de2898a26e035c49bc83d9dc83a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 12 Mar 2026 00:18:08 +0000 Subject: [PATCH] refactor: address code review feedback - clean up test imports and add MAIL_PORT validation Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com> --- musicround/config.py | 5 ++++- tests/test_security.py | 3 +-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/musicround/config.py b/musicround/config.py index 7b7f53a..b972b55 100644 --- a/musicround/config.py +++ b/musicround/config.py @@ -62,7 +62,10 @@ class Config: DROPBOX_REDIRECT_URI = os.getenv("DROPBOX_REDIRECT_URI", "http://localhost:5000/users/dropbox/callback") MAIL_HOST = os.getenv("MAIL_HOST", "localhost") - MAIL_PORT = int(os.getenv("MAIL_PORT", "25")) + try: + MAIL_PORT = int(os.getenv("MAIL_PORT", "25")) + except (ValueError, TypeError): + MAIL_PORT = 25 MAIL_USE_TLS = os.getenv("MAIL_USE_TLS", "False") == "True" MAIL_USE_SSL = os.getenv("MAIL_USE_SSL", "False") == "True" MAIL_USERNAME = os.getenv("MAIL_USERNAME", "") diff --git a/tests/test_security.py b/tests/test_security.py index 1335026..005aa4b 100644 --- a/tests/test_security.py +++ b/tests/test_security.py @@ -3,6 +3,7 @@ import pytest import os import re import importlib +import musicround.config class TestSecurityConfiguration: @@ -17,7 +18,6 @@ class TestSecurityConfiguration: try: # Force module reload to re-evaluate class-level checks - import musicround.config with pytest.raises(ValueError, match="SECRET_KEY environment variable must be set"): importlib.reload(musicround.config) finally: @@ -36,7 +36,6 @@ class TestSecurityConfiguration: try: # Force module reload to re-evaluate class-level checks - import musicround.config with pytest.raises(ValueError, match="AUTOMATION_TOKEN environment variable must be set"): importlib.reload(musicround.config) finally: