Skip to content

Commit 4aa443b

Browse files
Updated Tests (#240)
2 parents 390260a + 81dd667 commit 4aa443b

File tree

4 files changed

+93
-2
lines changed

4 files changed

+93
-2
lines changed

.github/workflows/pytest.yml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,20 @@ on:
99
jobs:
1010
build:
1111
runs-on: ubuntu-latest
12+
services:
13+
postgres:
14+
image: postgres:16
15+
env:
16+
POSTGRES_USER: postgres
17+
POSTGRES_PASSWORD: postgres_password
18+
POSTGRES_DB: labconnect
19+
ports:
20+
- 5432:5432
21+
options: >-
22+
--health-cmd="pg_isready -U postgres -d labconnect"
23+
--health-interval=10s
24+
--health-timeout=5s
25+
--health-retries=3
1226
strategy:
1327
matrix:
1428
python-version: ["3.12.4"]
@@ -22,9 +36,19 @@ jobs:
2236
run: |
2337
python -m pip install --upgrade pip
2438
pip install -r requirements.txt
25-
- name: Setup the Database
39+
- name: Wait for PostgreSQL to be ready
40+
run: |
41+
while ! pg_isready -h localhost -p 5432 -U postgres -d labconnect; do
42+
echo "Waiting for PostgreSQL..."
43+
sleep 2
44+
done
45+
- name: Set up the Database
46+
env:
47+
DATABASE_URL: postgresql+psycopg2://postgres:postgres_password@localhost/labconnect
2648
run: |
2749
python db_init.py create
2850
- name: Running pytest
51+
env:
52+
DATABASE_URL: postgresql+psycopg2://postgres:postgres_password@localhost/labconnect
2953
run: |
3054
python -m pytest tests/

tests/test_departments.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,51 @@ def test_departments_route(test_client: FlaskClient) -> None:
3737
"space, the final frontier",
3838
"flying, need for speed",
3939
),
40+
(
41+
"School of science",
42+
"School of science",
43+
"School of engineering",
44+
"School of science",
45+
"School of engineering",
46+
"School of engineering",
47+
"School of engineering",
48+
),
49+
(
50+
"CSCI",
51+
"BIOL",
52+
"MTLE" "MATH",
53+
"ENVI",
54+
"MANE",
55+
"MANE",
56+
),
57+
(
58+
"https://cdn-icons-png.flaticon.com/512/5310/5310672.png",
59+
"https://cdn-icons-png.flaticon.com/512/5310/5310672.png",
60+
"https://cdn-icons-png.flaticon.com/512/5310/5310672.png"
61+
"https://cdn-icons-png.flaticon.com/512/5310/5310672.png",
62+
"https://cdn-icons-png.flaticon.com/512/5310/5310672.png",
63+
"https://cdn-icons-png.flaticon.com/512/5310/5310672.png",
64+
"https://cdn-icons-png.flaticon.com/512/5310/5310672.png",
65+
),
66+
(
67+
"https://www.rpi.edu",
68+
"https://www.rpi.edu",
69+
"https://www.rpi.edu",
70+
"https://www.rpi.edu",
71+
"https://www.rpi.edu",
72+
"https://www.rpi.edu",
73+
"https://www.rpi.edu",
74+
),
4075
)
4176

4277
for department in json_data:
4378
assert department["name"] in rpi_departments_data[0]
4479
assert department["description"] in rpi_departments_data[1]
80+
# Added
81+
assert department["school_id"] in rpi_departments_data[2]
82+
assert department["id"] in rpi_departments_data[3]
83+
assert department["image"] in rpi_departments_data[4]
84+
assert department["webcite"] in rpi_departments_data[5]
4585

4686

4787
def test_department_route(test_client: FlaskClient) -> None:
@@ -59,6 +99,12 @@ def test_department_route(test_client: FlaskClient) -> None:
5999
assert json_data["name"] == "Computer Science"
60100
assert json_data["description"] == "DS"
61101
assert json_data["school_id"] == "School of Science"
102+
# Added
103+
assert json_data["id"] == "CSCI"
104+
assert (
105+
json_data["image"] == "https://cdn-icons-png.flaticon.com/512/5310/5310672.png"
106+
)
107+
assert json_data["webcite"] == "https://www.rpi.edu"
62108

63109
prof_names = ["Duy Le", "Rafael", "Turner", "Kuzmin", "Goldschmidt"]
64110
prof_rcs_ids = ["led", "cenzar", "turner", "kuzmin", "goldd"]

tests/test_lab_manager.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def test_lab_manager_route_with_input_id(test_client: FlaskClient) -> None:
2525
"alt_email": None,
2626
"phone_number": None,
2727
"email": None,
28+
"description": None,
2829
}
2930

3031
assert json_data == cenzar_data

tests/test_user.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,20 @@ def test_user_route_with_input_id_1(test_client: FlaskClient) -> None:
2020

2121
assert json_data["id"] == 1
2222
assert json_data["first_name"] == "Rafael"
23-
assert json_data["last_name"] == "Cenzano"
2423
assert json_data["preferred_name"] == "Raf"
24+
assert json_data["last_name"] == "Cenzano"
2525
assert json_data["email"] == "[email protected]"
26+
# Added
27+
assert json_data["description"] == "labconnect is the best RCOS project"
28+
assert (
29+
json_data["profile_picture"]
30+
== "https://rafael.sirv.com/Images/rafael.jpeg?thumbnail=350&format=webp&q=90"
31+
)
32+
assert json_data["website"] == "https://rafaelcenzano.com"
33+
# class year
34+
assert json_data["class_year"] == "2025"
35+
# lab manager id
36+
assert json_data["lab_manager_id"] == 1
2637

2738
departments_data = [
2839
{"user_id": 1, "department_id": "Computer Science"},
@@ -104,6 +115,15 @@ def test_user_route_with_input_id_2(test_client: FlaskClient) -> None:
104115
assert json_data["last_name"] == "RCOS"
105116
assert json_data["preferred_name"] is None
106117
assert json_data["email"] == "[email protected]"
118+
# Added
119+
assert json_data["description"] is None
120+
assert (
121+
json_data["profile_picture"]
122+
== "https://www.svgrepo.com/show/206842/professor.svg"
123+
) # Adjust based on your test data
124+
assert json_data["website"] is None
125+
assert json_data["class_year"] is None
126+
assert json_data["lab_manager_id"] is None
107127

108128
departments_data = [
109129
{"department_id": "Computer Science", "user_id": 2},

0 commit comments

Comments
 (0)