diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 91267bca..b7fdd24b 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -9,6 +9,20 @@ on: jobs: build: runs-on: ubuntu-latest + services: + postgres: + image: postgres:16 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres_password + POSTGRES_DB: labconnect + ports: + - 5432:5432 + options: >- + --health-cmd="pg_isready -U postgres -d labconnect" + --health-interval=10s + --health-timeout=5s + --health-retries=3 strategy: matrix: python-version: ["3.12.4"] @@ -22,9 +36,19 @@ jobs: run: | python -m pip install --upgrade pip pip install -r requirements.txt - - name: Setup the Database + - name: Wait for PostgreSQL to be ready + run: | + while ! pg_isready -h localhost -p 5432 -U postgres -d labconnect; do + echo "Waiting for PostgreSQL..." + sleep 2 + done + - name: Set up the Database + env: + DATABASE_URL: postgresql+psycopg2://postgres:postgres_password@localhost/labconnect run: | python db_init.py create - name: Running pytest + env: + DATABASE_URL: postgresql+psycopg2://postgres:postgres_password@localhost/labconnect run: | python -m pytest tests/ diff --git a/tests/test_departments.py b/tests/test_departments.py index 445cd3c1..7f64ac18 100644 --- a/tests/test_departments.py +++ b/tests/test_departments.py @@ -37,11 +37,51 @@ def test_departments_route(test_client: FlaskClient) -> None: "space, the final frontier", "flying, need for speed", ), + ( + "School of science", + "School of science", + "School of engineering", + "School of science", + "School of engineering", + "School of engineering", + "School of engineering", + ), + ( + "CSCI", + "BIOL", + "MTLE" "MATH", + "ENVI", + "MANE", + "MANE", + ), + ( + "https://cdn-icons-png.flaticon.com/512/5310/5310672.png", + "https://cdn-icons-png.flaticon.com/512/5310/5310672.png", + "https://cdn-icons-png.flaticon.com/512/5310/5310672.png" + "https://cdn-icons-png.flaticon.com/512/5310/5310672.png", + "https://cdn-icons-png.flaticon.com/512/5310/5310672.png", + "https://cdn-icons-png.flaticon.com/512/5310/5310672.png", + "https://cdn-icons-png.flaticon.com/512/5310/5310672.png", + ), + ( + "https://www.rpi.edu", + "https://www.rpi.edu", + "https://www.rpi.edu", + "https://www.rpi.edu", + "https://www.rpi.edu", + "https://www.rpi.edu", + "https://www.rpi.edu", + ), ) for department in json_data: assert department["name"] in rpi_departments_data[0] assert department["description"] in rpi_departments_data[1] + # Added + assert department["school_id"] in rpi_departments_data[2] + assert department["id"] in rpi_departments_data[3] + assert department["image"] in rpi_departments_data[4] + assert department["webcite"] in rpi_departments_data[5] def test_department_route(test_client: FlaskClient) -> None: @@ -59,6 +99,12 @@ def test_department_route(test_client: FlaskClient) -> None: assert json_data["name"] == "Computer Science" assert json_data["description"] == "DS" assert json_data["school_id"] == "School of Science" + # Added + assert json_data["id"] == "CSCI" + assert ( + json_data["image"] == "https://cdn-icons-png.flaticon.com/512/5310/5310672.png" + ) + assert json_data["webcite"] == "https://www.rpi.edu" prof_names = ["Duy Le", "Rafael", "Turner", "Kuzmin", "Goldschmidt"] prof_rcs_ids = ["led", "cenzar", "turner", "kuzmin", "goldd"] diff --git a/tests/test_lab_manager.py b/tests/test_lab_manager.py index 0cea0a03..7e288834 100644 --- a/tests/test_lab_manager.py +++ b/tests/test_lab_manager.py @@ -25,6 +25,7 @@ def test_lab_manager_route_with_input_id(test_client: FlaskClient) -> None: "alt_email": None, "phone_number": None, "email": None, + "description": None, } assert json_data == cenzar_data diff --git a/tests/test_user.py b/tests/test_user.py index ab075777..122a7c63 100644 --- a/tests/test_user.py +++ b/tests/test_user.py @@ -20,9 +20,20 @@ def test_user_route_with_input_id_1(test_client: FlaskClient) -> None: assert json_data["id"] == 1 assert json_data["first_name"] == "Rafael" - assert json_data["last_name"] == "Cenzano" assert json_data["preferred_name"] == "Raf" + assert json_data["last_name"] == "Cenzano" assert json_data["email"] == "cenzar@rpi.edu" + # Added + assert json_data["description"] == "labconnect is the best RCOS project" + assert ( + json_data["profile_picture"] + == "https://rafael.sirv.com/Images/rafael.jpeg?thumbnail=350&format=webp&q=90" + ) + assert json_data["website"] == "https://rafaelcenzano.com" + # class year + assert json_data["class_year"] == "2025" + # lab manager id + assert json_data["lab_manager_id"] == 1 departments_data = [ {"user_id": 1, "department_id": "Computer Science"}, @@ -104,6 +115,15 @@ def test_user_route_with_input_id_2(test_client: FlaskClient) -> None: assert json_data["last_name"] == "RCOS" assert json_data["preferred_name"] is None assert json_data["email"] == "test@rpi.edu" + # Added + assert json_data["description"] is None + assert ( + json_data["profile_picture"] + == "https://www.svgrepo.com/show/206842/professor.svg" + ) # Adjust based on your test data + assert json_data["website"] is None + assert json_data["class_year"] is None + assert json_data["lab_manager_id"] is None departments_data = [ {"department_id": "Computer Science", "user_id": 2},