diff --git a/.github/workflows/ci_airflow.yml b/.github/workflows/ci_airflow.yml index 373b67f..2d4b060 100644 --- a/.github/workflows/ci_airflow.yml +++ b/.github/workflows/ci_airflow.yml @@ -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 \ No newline at end of file + python /airflow/dags/scrapping.py + python /airflow/dags/predict_surprise_SVD.py + python /airflow/dags/predict_knn_model.py \ No newline at end of file diff --git a/.github/workflows/test-databases.yml b/.github/workflows/test-databases.yml index 84fff1c..5e45c91 100644 --- a/.github/workflows/test-databases.yml +++ b/.github/workflows/test-databases.yml @@ -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 \ No newline at end of file diff --git a/tests/requirements-test.txt b/tests/requirements-test.txt index d9ab17b..2db2ad7 100644 --- a/tests/requirements-test.txt +++ b/tests/requirements-test.txt @@ -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 diff --git a/tests/test_app.py b/tests/test_app.py index db9543c..86b2875 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -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() diff --git a/tests/test_db_creation.sql b/tests/test_db_creation.sql index 48e2d6c..19714da 100644 --- a/tests/test_db_creation.sql +++ b/tests/test_db_creation.sql @@ -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';