Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Commit

Permalink
pytest test first pass
Browse files Browse the repository at this point in the history
  • Loading branch information
cisaacstern committed Dec 7, 2023
1 parent 8dca201 commit 21f3623
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
22 changes: 15 additions & 7 deletions .github/workflows/test-db-backup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.10

- name: Install python deps
run: |
python -m pip install pytest sqlmodel psycopg2-binary
python -m pip install . --no-deps
- name: Install PostgreSQL client
run: |
sudo apt-get update
Expand All @@ -50,11 +60,9 @@ jobs:
env:
PGPASSWORD: postgres_password

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.10

- name: Install python deps
- name: Test restored database
if: always()
run: |
python -m pip install pytest
pytest -vvxs db-backup/test_db_backup.py
env:
DATABASE_URL: postgresql://postgres_user:postgres_password@localhost:5432/postgres_db
15 changes: 15 additions & 0 deletions db-backup/test_db_backup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import os

from sqlmodel import Session, create_engine, select

from pangeo_forge_orchestrator.models import MODELS


def test_db_backup():
database_url = os.environ["DATABASE_URL"]
connect_args = dict(options="-c timezone=utc")
engine = create_engine(database_url, echo=False, connect_args=connect_args)
with Session(engine) as session:
statement = select(MODELS["feedstock"].table)
fstocks = session.exec(statement).all()
print(fstocks)

0 comments on commit 21f3623

Please sign in to comment.