Skip to content

Commit de59661

Browse files
committed
test db address fixes, and more POSTGRES_URL fixes
1 parent 7daffa4 commit de59661

File tree

5 files changed

+19
-3
lines changed

5 files changed

+19
-3
lines changed

.github/workflows/deploy.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ jobs:
88
deploy:
99
runs-on: ubuntu-latest
1010

11+
env:
12+
IMAGE: us-central1-docker.pkg.dev/freeway2026/fec/fec:latest
13+
1114
steps:
1215
- uses: actions/checkout@v4
1316

@@ -22,7 +25,6 @@ jobs:
2225

2326
- name: Build & Push Image
2427
run: |
25-
IMAGE=us-central1-docker.pkg.dev/freeway2026/fec/fec:latest
2628
docker build -t $IMAGE .
2729
docker push $IMAGE
2830

app/db.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def get_engine():
1010
)
1111

1212

13-
def create_tables(database_url: str, echo: bool = False) -> None:
13+
def create_tables(database_url: str = POSTGRES_URL, echo: bool = False) -> None:
1414
engine = create_engine(database_url, echo=echo)
1515
SQLModel.metadata.create_all(engine)
1616

app/main.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from app.query import fetch, FetchRun
22
from app.ingestion import ingest_jsonl
33
from app.mail import send_email
4+
from app.logger import logger
45
from app.db import get_engine, create_tables
56
from app.helpers import get_now, format_results, get_today
67
from app.config import CYCLE
@@ -57,8 +58,10 @@ def run(variant, key, cycle):
5758
if __name__ == "__main__":
5859
today = get_today()
5960
create_tables()
61+
logger.info("Running...")
6062
run(
6163
variant="expenditure",
6264
key=today,
6365
cycle=CYCLE
6466
)
67+
logger.info("Run complete.")

scripts/stop_test_db.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#!/usr/bin/env bash
2-
docker stop fec-test-db
2+
docker stop test_db

tests/conftest.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import pytest
22
from sqlmodel import SQLModel
3+
import os
34
from app.db import get_engine
45
from app.config import DATA_DIR
56
from tests.helpers import reset_data_dir
@@ -17,6 +18,16 @@ def engine():
1718
SQLModel.metadata.drop_all(engine)
1819

1920

21+
@pytest.fixture(scope="session", autouse=True)
22+
def set_test_postgres_url():
23+
# this is hard-wired in start_test_db.sh
24+
os.environ["POSTGRES_URL"] = (
25+
"postgresql+psycopg2://postgres:postgres@localhost:5433/test_db"
26+
)
27+
yield
28+
os.environ.pop("POSTGRES_URL", None)
29+
30+
2031
@pytest.fixture
2132
def clean_data_dir():
2233
reset_data_dir(DATA_DIR)

0 commit comments

Comments
 (0)