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/Worker.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'Biz/PodcastItLater/Worker.py') diff --git a/Biz/PodcastItLater/Worker.py b/Biz/PodcastItLater/Worker.py index 834d44b..ce3d432 100644 --- a/Biz/PodcastItLater/Worker.py +++ b/Biz/PodcastItLater/Worker.py @@ -41,7 +41,14 @@ S3_ENDPOINT = os.getenv("S3_ENDPOINT") S3_BUCKET = os.getenv("S3_BUCKET") S3_ACCESS_KEY = os.getenv("S3_ACCESS_KEY") S3_SECRET_KEY = os.getenv("S3_SECRET_KEY") -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") # Worker configuration MAX_CONTENT_LENGTH = 5000 # characters for TTS @@ -943,7 +950,12 @@ class TestJobProcessing(Test.TestCase): def setUp(self) -> None: """Set up test environment.""" - self.test_db = "test_podcast_worker.db" + self.test_db = "_/var/podcastitlater/test_podcast_worker.db" + + # Ensure test directory exists + test_db_dir = pathlib.Path(self.test_db).parent + test_db_dir.mkdir(parents=True, exist_ok=True) + # Clean up any existing test database test_db_path = pathlib.Path(self.test_db) if test_db_path.exists(): -- cgit v1.2.3