-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* user_course_get_success * create a user course delete success function * update the delete failure function and add code to log out the session in the success cases * add failure cases for get and delete * add failure cases for get and delete * Update test_user_course_delete.py Change ways of writing to examine whether the course is successfully delete or not * delete trivial spaces and all the prints Co-authored-by: Xies3 <[email protected]>
- Loading branch information
Showing
2 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from .util import Client | ||
|
||
TEST_USER = { 'email': '[email protected]', | ||
'password': '123456' } | ||
|
||
TEST_COURSE = {'name': 'ARCH-4770', | ||
'cid': '-1', | ||
'semester': 'SUMMER2020'} | ||
|
||
TEST_COURSE_2 = {'name': 'ARCH-4770', | ||
'cid': None, | ||
'semester': 'SUMMER2020'} | ||
|
||
|
||
def test_user_course_delete_success(post_user, client: Client): | ||
r = client.post("/api/session", json=TEST_USER) | ||
assert r.status_code == 200 | ||
course = client.post("/api/user/course", json=TEST_COURSE) | ||
assert course.status_code == 200 | ||
d = client.get("/api/user/course", json=TEST_COURSE) | ||
data = d.json()[1] | ||
assert data['course_name'] == TEST_COURSE['name'] | ||
assert data['crn'] == TEST_COURSE['cid'] | ||
assert data['semester'] == TEST_COURSE['semester'] | ||
x = client.delete("/api/user/course", json = TEST_COURSE) | ||
assert x.status_code == 200 | ||
d = client.get("/api/user/course", json=TEST_COURSE) | ||
data = d.json() | ||
for x in data: | ||
assert x['course_name'] is not TEST_COURSE['name'] | ||
assert x['crn'] is not TEST_COURSE['cid'] | ||
client.delete("/api/session", json = {"sessionID": r.json()["content"]["sessionID"]}) | ||
|
||
def test_user_course_delete_failure(client: Client): | ||
r = client.post("/api/user/course", json=TEST_USER) | ||
assert r.status_code == 403 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from .util import Client | ||
|
||
TEST_USER = { 'email': '[email protected]', | ||
'password': '123456' } | ||
|
||
TEST_COURSE = {'name': 'ARCH-4770', | ||
'cid': '-1', | ||
'semester': 'SUMMER2020'} | ||
|
||
|
||
def test_user_course_get_success(post_user, client: Client): | ||
r = client.post("/api/session", json=TEST_USER) | ||
assert r.status_code == 200 | ||
course = client.post("/api/user/course", json=TEST_COURSE) | ||
assert course.status_code == 200 | ||
d = client.get("/api/user/course", json=TEST_COURSE) | ||
data = d.json()[1] | ||
assert data['course_name'] == TEST_COURSE['name'] | ||
assert data['crn'] == TEST_COURSE['cid'] | ||
assert data['semester'] == TEST_COURSE['semester'] | ||
client.delete("/api/session", json = {"sessionID": r.json()["content"]["sessionID"]}) | ||
|
||
def test_user_course_get_failure(client: Client): | ||
r = client.post("/api/user/course", json = TEST_COURSE) | ||
assert r.status_code == 403 | ||
|