Skip to content

Commit

Permalink
Create test_user_course.py
Browse files Browse the repository at this point in the history
  • Loading branch information
yliao-dev committed Feb 11, 2022
1 parent 4c1d470 commit 841505d
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/api/tests/test_user_course.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from .util import Client
from .fixtures import *

TEST_USER = { 'email': TEST_USER_SIGNUP['email'],
'password': TEST_USER_SIGNUP['password'] }

# TEST_USER_SIGNUP = { 'email': 'test@email.com',
# 'name': 'TestName',
# 'phone': '',
# 'password': '123456',
# 'degree': 'Undergraduate',
# 'major': 'CSCI' }
def test_user_course_post_success(post_user, client: Client):
'''
Test user course post by comparing it to user course get
'''

s = client.post("/api/session", json=TEST_USER)
assert s.status_code == 200

r = client.post("/api/user/course", json={
"name": "ADMN-1824",
"semester": "SUMMER 2020",
"cid": "-1"
})
assert r.status_code == 200
data = r.json()
g = client.get("/api/user/course", json=TEST_USER)
get_data = g.json()
print(get_data)
assert data['content'] is not None
assert data['content']['course_name'] is not None
assert data['content']['crn'] is not None
assert data['content']['semester'] is not None

assert data['content']['course_name'] == get_data['content']['course_name']

def test_user_course_post_failure(client: Client):
'''
Test user course post with invalid credentials
'''
# r = client.post("/api/user/course", json={'name':'NotAUser', 'password':'000000'})
# assert r.status_code == 200

# data = r.json()
# assert data['content'] is None

0 comments on commit 841505d

Please sign in to comment.