Skip to content

Commit

Permalink
pytest yml fix, generate dummy env file to proceed further
Browse files Browse the repository at this point in the history
SharathChampzz committed Dec 20, 2024
1 parent fcd9294 commit 2d12bf5
Showing 2 changed files with 21 additions and 8 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
@@ -30,4 +30,11 @@ jobs:
- name: Run Pytest
run: |
cd backend
pytest -p no:warnings
pytest -p no:warnings
- name: Create .env file
run: |
cd backend
echo "secret_key=your_secret_key_value" >> .env
echo "token_refresh_key=your_refresh_secret_key_value" >> .env
echo "database_url=sqlite:///./database/community_streak.db" >> .env
echo "debug_level=10" >> .env
20 changes: 13 additions & 7 deletions backend/tests/test_main.py
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
"""

import os

# before importing set the required env variables
os.environ["SECRET_KEY"] = "your_secret_key_value"
os.environ["REFRESH_SECRET_KEY"] = "your_refresh_secret_key_value"
@@ -12,25 +13,30 @@

from fastapi.testclient import TestClient
from app.main import app

client = TestClient(app)


def test_read_root():
""" Test the root endpoint """
"""Test the root endpoint"""
response = client.get("/")
assert response.status_code == 200
assert response.json() == {"Status": "WebService is Running!"}


def test_user_routes():
""" Test the user routes """
"""Test the user routes"""
response = client.get("/api/v1/users")
assert response.status_code == 200 or response.status_code == 404
assert response.status_code in [200, 404]


def test_event_routes():
""" Test the event routes """
"""Test the event routes"""
response = client.get("/api/v1/events")
assert response.status_code == 200 or response.status_code == 401
assert response.status_code in [200, 401]


def test_websocket_routes():
""" Test the websocket routes """
"""Test the websocket routes"""
response = client.get("/ws")
assert response.status_code == 200 or response.status_code == 404
assert response.status_code in [200, 404]

0 comments on commit 2d12bf5

Please sign in to comment.