commit
a4b8e96a14
2 changed files with 55 additions and 10 deletions
|
@ -3,7 +3,8 @@ import unittest
|
|||
import requests
|
||||
from Testing.config import __CONFIG__
|
||||
class UserTestPlan(unittest.TestCase):
|
||||
def setUpClass(cls):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
debug = __CONFIG__['DEBUG']
|
||||
if debug:
|
||||
url = __CONFIG__['PATHS']['DEBUG']
|
||||
|
@ -14,13 +15,17 @@ class UserTestPlan(unittest.TestCase):
|
|||
if 200 <= request.status_code <= 299:
|
||||
print 'Initialized'
|
||||
|
||||
def test_Campuses_invalid(self):
|
||||
r = requests.get(self.__class__.url_+'api/Campuses/invalidtoken')
|
||||
self.assertEquals(r.status_code, 403)
|
||||
def test_Campuses_valid(self):
|
||||
r = requests.get(self.__class__.url_+'api/Campuses/'+__CONFIG__['TOKENS']['STUDENT'])
|
||||
self.assertEquals(r.status_code, 200)
|
||||
self.assertEquals(r.json()['username'], 'qa_student')
|
||||
def test_campusesGet_invalidToken(self):
|
||||
r = requests.get(self.__class__.url_+'api/campuses/getAll/invalidtoken')
|
||||
self.assertEquals(r.status_code, 403)
|
||||
|
||||
def test_campusesGet_validToken_testArraySize(self):
|
||||
r = requests.get(self.__class__.url_+'api/campuses/getAll/'+__CONFIG__['TOKENS']['STUDENT'])
|
||||
self.assertEquals(r.status_code, 200)
|
||||
self.assertTrue(len(r.json())>= 1)
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
|
@ -18,7 +18,7 @@ class UserTestPlan(unittest.TestCase):
|
|||
|
||||
def test_getUserByToken_invalid(self):
|
||||
r = requests.get(self.__class__.url_+'api/users/getUserByToken/invalidtoken')
|
||||
self.assertEquals(r.status_code, 403)
|
||||
self.assertEquals(r.status_code, 204)
|
||||
|
||||
def test_getUserByToken_valid(self):
|
||||
r = requests.get(self.__class__.url_+'api/users/getUserByToken/'+__CONFIG__['TOKENS']['STUDENT'])
|
||||
|
@ -27,7 +27,7 @@ class UserTestPlan(unittest.TestCase):
|
|||
|
||||
def test_getUserByToken_empty(self):
|
||||
r = requests.get(self.__class__.url_+'api/users/getUserByToken/')
|
||||
self.assertEquals(r.status_code, 400)
|
||||
self.assertEquals(r.status_code, 204)
|
||||
|
||||
def test_isStudent_Student(self):
|
||||
r = requests.get(self.__class__.url_+'api/users/getUserByToken/'+__CONFIG__['TOKENS']['STUDENT'])
|
||||
|
@ -39,6 +39,46 @@ class UserTestPlan(unittest.TestCase):
|
|||
self.assertEquals(r.status_code, 200)
|
||||
self.assertTrue(r.json()['isLecturer'])
|
||||
|
||||
def test_isFirstLogin_Student(self):
|
||||
r = requests.get(self.__class__.url_+'api/users/getUserByToken/'+__CONFIG__['TOKENS']['STUDENT'])
|
||||
self.assertEquals(r.status_code, 200)
|
||||
self.assertTrue(r.json()['isFirstLogin'])
|
||||
|
||||
def test_isFirstLogin_Lecturer(self):
|
||||
r = requests.get(self.__class__.url_+'api/users/getUserByToken/'+__CONFIG__['TOKENS']['LECTURER'])
|
||||
self.assertEquals(r.status_code, 200)
|
||||
self.assertTrue(r.json()['isFirstLogin'])
|
||||
|
||||
def test_isClassIdListEmpty_Student(self):
|
||||
r = requests.get(self.__class__.url_+'api/users/getUserByToken/'+__CONFIG__['TOKENS']['STUDENT'])
|
||||
self.assertEquals(r.status_code, 200)
|
||||
self.assertEquals(r.json()['classes_id_list'],[])
|
||||
|
||||
def test_campuses_id_list_Student(self):
|
||||
r = requests.get(self.__class__.url_+'api/users/getUserByToken/'+__CONFIG__['TOKENS']['STUDENT'])
|
||||
self.assertEquals(r.status_code, 200)
|
||||
self.assertEquals(r.json()['campuses_id_list'],[])
|
||||
|
||||
def test_Student_isLecturer(self):
|
||||
r = requests.get(self.__class__.url_+'api/users/getUserByToken/'+__CONFIG__['TOKENS']['STUDENT'])
|
||||
self.assertEquals(r.status_code, 200)
|
||||
self.assertFalse(r.json()['isLecturer'])
|
||||
|
||||
def test_Lecturer_isLecturer(self):
|
||||
r = requests.get(self.__class__.url_+'api/users/getUserByToken/'+__CONFIG__['TOKENS']['LECTURER'])
|
||||
self.assertEquals(r.status_code, 200)
|
||||
self.assertFalse(r.json()['isLecturer'])
|
||||
|
||||
def test_isClassIdListEmpty_Lecturer(self):
|
||||
r = requests.get(self.__class__.url_+'api/users/getUserByToken/'+__CONFIG__['TOKENS']['LECTURER'])
|
||||
self.assertEquals(r.status_code, 200)
|
||||
self.assertEquals(r.json()['classes_id_list'],[])
|
||||
|
||||
def test_campuses_id_list_Lecturer(self):
|
||||
r = requests.get(self.__class__.url_+'api/users/getUserByToken/'+__CONFIG__['TOKENS']['LECTURER'])
|
||||
self.assertEquals(r.status_code, 200)
|
||||
self.assertEquals(r.json()['campuses_id_list'],[])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
Loading…
Reference in a new issue