Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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/
46 changes: 46 additions & 0 deletions tests/test_departments.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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"]
Expand Down
1 change: 1 addition & 0 deletions tests/test_lab_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 21 additions & 1 deletion tests/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"] == "[email protected]"
# 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"},
Expand Down Expand Up @@ -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"] == "[email protected]"
# 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},
Expand Down
Loading