From 48fdb6610957d213739f2cc84bc4c9071be909ac Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Wed, 3 Sep 2025 16:46:30 -0400 Subject: Add Environment-Aware Database Path Handling --- Biz/PodcastItLater/Web.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'Biz/PodcastItLater/Web.py') diff --git a/Biz/PodcastItLater/Web.py b/Biz/PodcastItLater/Web.py index b471a29..86b2099 100644 --- a/Biz/PodcastItLater/Web.py +++ b/Biz/PodcastItLater/Web.py @@ -50,7 +50,14 @@ from typing import override logger = Log.setup() # Configuration -DATABASE_PATH = os.getenv("DATABASE_PATH", "podcast.db") +area = App.from_env() +if area == App.Area.Test: + DATABASE_PATH = os.getenv( + "DATABASE_PATH", + "_/var/podcastitlater/podcast.db", + ) +else: + DATABASE_PATH = os.getenv("DATABASE_PATH", "/var/podcastitlater/podcast.db") BASE_URL = os.getenv("BASE_URL", "http://localhost:8000") PORT = int(os.getenv("PORT", "8000")) @@ -1751,7 +1758,11 @@ class BaseWebTest(Test.TestCase): def setUp(self) -> None: """Set up test database and client.""" # Create a test database context - self.test_db_path = "test_podcast_web.db" + self.test_db_path = "_/var/podcastitlater/test_podcast_web.db" + + # Ensure test directory exists + test_db_dir = pathlib.Path(self.test_db_path).parent + test_db_dir.mkdir(parents=True, exist_ok=True) # Save original database path self._original_db_path = globals()["_test_database_path"] -- cgit v1.2.3