Skip to content

Commit

Permalink
updated workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
Nneji123 committed Jan 8, 2024
1 parent 08ff738 commit 52e59a6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ jobs:
with:
python-version: '3.11'
- name: Install requirements
run: pip install -r api/requirements.txt
run: pip install -r api/requirements.txt \
python api/init_db.py

- name: Run tests and collect coverage
run: pytest --cov=api.public.towns.routes tests/test_towns.py --cov-report=xml
- name: Upload coverage reports to Codecov
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ jobs:
- name: Run Tests
run: |
echo "${{ secrets.ENV_FILE }}" > .env
pip install -r api/requirements.txt
pip install -r api/requirements.txt \
python api/init_db.py
pytest test/test_towns.py
16 changes: 16 additions & 0 deletions api/init_db.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from sqlalchemy.ext.asyncio import AsyncSession, create_async_engine
from sqlalchemy.orm import sessionmaker
from sqlmodel import Session, SQLModel, create_engine
from sqlmodel.ext.asyncio import session

from api.database import create_db_and_tables, create_town_and_people, get_db


def create_database_for_tests():
db = next(get_db()) # Fetching the database session
create_db_and_tables()
try:
create_town_and_people(db)
except (IntegrityError, Exception) as e:
# Perform any cleanup or teardown operations if needed
pass

0 comments on commit 52e59a6

Please sign in to comment.