Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

semester and subsemester tests #536

Merged
merged 3 commits into from
Feb 18, 2022
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
14 changes: 14 additions & 0 deletions src/api/tests/test_semester.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

from .util import Client

def test_semester(upload, client):
"""
semester endpoint should get all of the semesters in the upload
in the case of our test data, we should be getting get 2 semesters: "SUMMER 2020" and "SPRING 2020"
"""
r = client.get("/api/semester")
print(r.text)
data = r.json()
assert len(data) == 2
assert data[0]["semester"] == "SUMMER 2020"
assert data[1]["semester"] == "SPRING 2020"
39 changes: 39 additions & 0 deletions src/api/tests/test_subsemester.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from .util import Client


def test_subsemeseter_spring2020(client, upload):
"""
when subsemester endpoint is given an input such as Spring 2020
it should only return data for that subsemester i.e. data where the parent semester name
is "SPRING 2020".
"""
r = client.get("/api/subsemester",
params={"semester":"SPRING 2020"})
assert r.status_code == 200
data = r.json()
assert len(data) == 1
assert data[0]["parent_semester_name"] == "SPRING 2020"

def test_subsemester_nosemester(client, upload):
"""
when no subsemester is taken as input the subsemester endpoint should return all of the subsemesters
contained in the upload data.
Specifically there should be 4 total returned semesters
"""
r = client.get("/api/subsemester")
assert r.status_code == 200
data = r.json()
assert len(data) == 4

def test_subsemester_invalid_semester(client):
"""
invalid input to subsemester to subsemester endpoint such as "moon 2050"
should result in an empty list of semester data being returned.
The status should still be success, and size of the data should be 0.
"""
r = client.get("/api/subsemester", params={"semester":"moon 2050"})
print(r.text)
assert r.status_code == 200
data = r.json()
assert len(data) == 0