UserApi_Test - test getuserbytoken with valid,invalid and empty string
CampusesApi_test - with valid,invalid string
This commit is contained in:
parent
d15adbd1a8
commit
0818060378
4 changed files with 49 additions and 18 deletions
|
@ -5,27 +5,39 @@ from Testing.config import __CONFIG__
|
||||||
class CampusTestPlan(unittest.TestCase):
|
class CampusTestPlan(unittest.TestCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
debug = __CONFIG__['DEBUG']
|
debug = __CONFIG__['DEBUG']
|
||||||
if debug:
|
if debug:
|
||||||
url = __CONFIG__['PATHS']['DEBUG']
|
url = __CONFIG__['PATHS']['DEBUG']
|
||||||
else:
|
else:
|
||||||
url = __CONFIG__['PATHS']['PRODUCTION']
|
url = __CONFIG__['PATHS']['PRODUCTION']
|
||||||
cls.url_ = url
|
cls.url_ = url
|
||||||
request = requests.get(url+'api/qa/init')
|
request = requests.get(url+'api/qa/init')
|
||||||
if 200 <= request.status_code <= 299:
|
if 200 <= request.status_code <= 299:
|
||||||
print 'Initialized'
|
print 'Initialized'
|
||||||
|
|
||||||
def test_campusesGet_invalidToken(self):
|
def test_campusesGet_invalidToken(self):
|
||||||
r = requests.get(self.__class__.url_+'api/campuses/getAll/invalidtoken')
|
r = requests.get(self.__class__.url_+'api/campuses/getAll/invalidtoken')
|
||||||
self.assertEquals(r.status_code, 403)
|
self.assertEquals(r.status_code, 403)
|
||||||
|
|
||||||
def test_campusesGet_validToken_testArraySize(self):
|
def test_campusesGet_validToken_testArraySize(self):
|
||||||
r = requests.get(self.__class__.url_+'api/campuses/getAll/'+__CONFIG__['TOKENS']['STUDENT'])
|
r = requests.get(self.__class__.url_+'api/campuses/getAll/'+__CONFIG__['TOKENS']['STUDENT'])
|
||||||
self.assertEquals(r.status_code, 200)
|
self.assertEquals(r.status_code, 200)
|
||||||
self.assertTrue(len(r.json())>= 1)
|
self.assertTrue(len(r.json())>= 1)
|
||||||
|
|
||||||
|
def test_campusCreate_Lecturer(self):
|
||||||
|
payload = {'title': 'Campus name', 'email_ending': '@campus.ac.com','avatar_url': 'http://location.domain.com/image.jpg'}
|
||||||
|
r = requests.post(self.__class__.url_+'api/campuses/create/'+__CONFIG__['TOKENS']['LECTURER'],data=payload)
|
||||||
|
self.assertEquals(r.status_code, 201)
|
||||||
|
|
||||||
|
def test_campusCreate_Student(self):
|
||||||
|
payload = {'title': 'Campus name', 'email_ending': '@campus.ac.com','avatar_url': 'http://location.domain.com/image.jpg'}
|
||||||
|
r = requests.post(self.__class__.url_+'api/campuses/create/'+__CONFIG__['TOKENS']['STUDENT'],data=payload)
|
||||||
|
self.assertEquals(r.status_code, 403)
|
||||||
|
|
||||||
|
def test_campusCreate_InvalidToken(self):
|
||||||
|
payload = {'title': 'Campus name', 'email_ending': '@campus.ac.com','avatar_url': 'http://location.domain.com/image.jpg'}
|
||||||
|
r = requests.post(self.__class__.url_+'api/campuses/create/invalidToken',data=payload)
|
||||||
|
self.assertEquals(r.status_code, 403)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
|
@ -16,17 +16,23 @@ class CoursesTestPlan(unittest.TestCase):
|
||||||
print 'Initialized'
|
print 'Initialized'
|
||||||
|
|
||||||
def test_coursesCreate_Lecturer(self):
|
def test_coursesCreate_Lecturer(self):
|
||||||
r = requests.get(self.__class__.url_+'api/courses/create/'+__CONFIG__['TOKENS']['LECTURER'])
|
payload = {'courseName': 'Advance Math', 'campusName': 'JCE', 'startDate':'2015-14-3','endDate': '2015-29-6','taskFlag': 'False'}
|
||||||
|
r = requests.post(self.__class__.url_+'api/courses/create/'+__CONFIG__['TOKENS']['LECTURER'],data=payload)
|
||||||
self.assertEquals(r.status_code, 201)
|
self.assertEquals(r.status_code, 201)
|
||||||
|
|
||||||
def test_coursesCreate_InvalidToken(self):
|
def test_coursesCreate_InvalidToken(self):
|
||||||
r = requests.get(self.__class__.url_+'api/courses/create/invalidToken')
|
payload = {'courseName': 'Advance Math', 'campusName': 'JCE', 'startDate':'2015-14-3','endDate': '2015-29-6','taskFlag': 'False'}
|
||||||
|
r = requests.post(self.__class__.url_+'api/courses/create/invalidToken',data=payload)
|
||||||
self.assertEquals(r.status_code, 403)
|
self.assertEquals(r.status_code, 403)
|
||||||
|
|
||||||
def test_coursesCreate_Student(self):
|
def test_coursesCreate_Student(self):
|
||||||
r = requests.get(self.__class__.url_+'api/courses/create/'+__CONFIG__['TOKENS']['STUDENT'])
|
payload = {'courseName': 'Advance Math', 'campusName': 'JCE', 'startDate':'2015-14-3','endDate': '2015-29-6','taskFlag': 'False'}
|
||||||
|
r = requests.post(self.__class__.url_+'api/courses/create/'+__CONFIG__['TOKENS']['STUDENT'],data=payload)
|
||||||
self.assertEquals(r.status_code, 403)
|
self.assertEquals(r.status_code, 403)
|
||||||
|
|
||||||
|
def test_getCourseByCampusName(self):
|
||||||
|
r = requests.get(self.__class__.url_+'api/courses/getCourseByCampusName/'+__CONFIG__['TOKENS']['CAMPUS_NAME'])
|
||||||
|
self.assertEquals(r.status_code, 200)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
|
@ -1,6 +1,7 @@
|
||||||
__author__ = 'etye'
|
__author__ = 'etye'
|
||||||
import unittest
|
import unittest
|
||||||
import requests
|
import requests
|
||||||
|
import json
|
||||||
from Testing.config import __CONFIG__
|
from Testing.config import __CONFIG__
|
||||||
|
|
||||||
class UserTestPlan(unittest.TestCase):
|
class UserTestPlan(unittest.TestCase):
|
||||||
|
@ -79,6 +80,17 @@ class UserTestPlan(unittest.TestCase):
|
||||||
self.assertEquals(r.status_code, 200)
|
self.assertEquals(r.status_code, 200)
|
||||||
self.assertEquals(r.json()['campuses_id_list'],[])
|
self.assertEquals(r.json()['campuses_id_list'],[])
|
||||||
|
|
||||||
|
def test_userUpdate_Student(self):
|
||||||
|
payload = {'name': 'New Name', 'isLecturer': 'false'}
|
||||||
|
r = requests.post(self.__class__.url_+'api/users/userUpdate/'+__CONFIG__['TOKENS']['STUDENT'],data=payload)
|
||||||
|
self.assertEquals(r.status_code, 200)
|
||||||
|
#data = {}
|
||||||
|
#data['name'] = 'New Name'
|
||||||
|
#data['isLecturer'] = 'false'
|
||||||
|
#json_data = json.dumps(data)
|
||||||
|
#r = requests.post(self.__class__.url_+'api/users/userUpdate/'+__CONFIG__['TOKENS']['STUDENT'],json_data)
|
||||||
|
#self.assertEquals(r.status_code, 200)
|
||||||
|
#self.assertEquals(r.json()['message'],'User updated')
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
|
@ -9,6 +9,7 @@ __CONFIG__ = {
|
||||||
},
|
},
|
||||||
'TOKENS':{
|
'TOKENS':{
|
||||||
'STUDENT': '_QA_TOKEN_TEST_STUDENT',
|
'STUDENT': '_QA_TOKEN_TEST_STUDENT',
|
||||||
'LECTURER': '_QA_TOKEN_TEST_LECTURER'
|
'LECTURER': '_QA_TOKEN_TEST_LECTURER',
|
||||||
|
'CAMPUS_NAME':'JCE'
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue