Skip to content

Commit

Permalink
🔨 Update tests files
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoinePELAMOURGUES committed Nov 19, 2024
1 parent 8fc67c7 commit 70d2a2f
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 13 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci_airflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ jobs:
- name: Run tests
run: |
python ../airflow/dags/scrapping.py
python ../airflow/dags/predict_surprise_SVD.py
python ../airflow/dags/predict_knn_model.py
python /airflow/dags/scrapping.py
python /airflow/dags/predict_surprise_SVD.py
python /airflow/dags/predict_knn_model.py
4 changes: 4 additions & 0 deletions .github/workflows/test-databases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ jobs:
python -m pip install --upgrade pip
pip install -r tests/requirements-test.txt
- name: Create database tables
run: |
psql postgresql://test_user:test_password@localhost:5432/test_db -f tests/test_db_creation.sql
- name: Run database tests
run: |
pytest tests/test_db.py
5 changes: 5 additions & 0 deletions tests/requirements-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,15 @@ python-multipart
pandas
numpy
scikit-learn
tqdm
bcrypt

# Test client for FastAPI
requests
passlib
rapidfuzz
python-jose[cryptography]
pydantic>=2.7.0,<3.0.0

# Test client for Airflow
apache-airflow
Expand Down
20 changes: 10 additions & 10 deletions tests/test_app.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
import streamlit as st
from streamlit.testing import StreamlitTestRunner
from streamlit.testing import TestClient
from streamlit.app.utils import display_movies_grid
from streamlit.app.pages import _4_Authentification, _5_Application

def test_display_movies_grid():
runner = StreamlitTestRunner()
client = TestClient(display_movies_grid)
movies_info = {
"0": {"poster_path": "path/to/poster1.jpg", "title": "Movie 1", "vote_average": 8.5},
"1": {"poster_path": "path/to/poster2.jpg", "title": "Movie 2", "vote_average": 7.3},
"2": {"poster_path": "path/to/poster3.jpg", "title": "Movie 3", "vote_average": 9.1},
"3": {"poster_path": "path/to/poster4.jpg", "title": "Movie 4", "vote_average": 6.8},
}
runner.run(display_movies_grid, movies_info)
assert runner.get_widget("markdown").exists()
client.run(movies_info)
assert client.get_widget("markdown").exists()

def test_authentication_page():
runner = StreamlitTestRunner()
runner.run(_4_Authentification)
assert runner.get_widget("header").exists()
client = TestClient(_4_Authentification)
client.run()
assert client.get_widget("header").exists()

def test_application_page():
runner = StreamlitTestRunner()
runner.run(_5_Application)
assert runner.get_widget("markdown").exists()
client = TestClient(_5_Application)
client.run()
assert client.get_widget("markdown").exists()

if __name__ == "__main__":
test_display_movies_grid()
Expand Down
24 changes: 24 additions & 0 deletions tests/test_db_creation.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
CREATE TABLE movies (
id SERIAL PRIMARY KEY,
title VARCHAR(255) NOT NULL,
genre VARCHAR(255) NOT NULL
);

CREATE TABLE ratings (
id SERIAL PRIMARY KEY,
movie_id INT REFERENCES movies(id),
rating INT NOT NULL
);

CREATE TABLE links (
id SERIAL PRIMARY KEY,
movie_id INT REFERENCES movies(id),
url VARCHAR(255) NOT NULL
);

CREATE TABLE users (
id SERIAL PRIMARY KEY,
username VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL
);

SELECT table_name
FROM information_schema.tables
WHERE table_schema = 'public';
Expand Down

0 comments on commit 70d2a2f

Please sign in to comment.