Added Tests CoursesApi - course create
UserApi - Fixed tests
This commit is contained in:
parent
02dc0c58ee
commit
faad6dae00
3 changed files with 63 additions and 10 deletions
|
@ -1,6 +1,7 @@
|
|||
__author__ = 'etye'
|
||||
import unittest
|
||||
import requests
|
||||
import json
|
||||
from Testing.config import __CONFIG__
|
||||
class CoursesTestPlan(unittest.TestCase):
|
||||
@classmethod
|
||||
|
@ -16,19 +17,71 @@ class CoursesTestPlan(unittest.TestCase):
|
|||
print 'Initialized'
|
||||
|
||||
def test_coursesCreate_Lecturer(self):
|
||||
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)
|
||||
headers = {'content-type': 'application/json'}
|
||||
url = 'http://se-hub.appspot.com/api/courses/create/_QA_TOKEN_TEST_LECTURER'
|
||||
params = {'seToken': 'seToken' }
|
||||
data = {
|
||||
'courseName': 'QA COURSE',
|
||||
'campusName': 'https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg',
|
||||
'projects': '@gay.lord.ultima.multi.omega',
|
||||
'startDate': {'year': 2015, 'month' : 4, 'day' : 3},
|
||||
'endDate': {'year': 2016,'month' : 6,'day' : 6}
|
||||
}
|
||||
|
||||
#r = requests.post(self.__class__.url_+'api/courses/create/'+__CONFIG__['TOKENS']['STUDENT'],data=payload)
|
||||
r = requests.post(url, params=params, data=json.dumps(data), headers=headers)
|
||||
'''
|
||||
payload = {
|
||||
'courseName': 'QA COURSE',
|
||||
'campusName': 'https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg',
|
||||
'projects': '@gay.lord.ultima.multi.omega',
|
||||
'startDate': {'year': 2015, 'month' : 4, 'day' : 3},
|
||||
'endDate': {'year': 2016,'month' : 6,'day' : 6}
|
||||
}
|
||||
'''
|
||||
# r = requests.post(self.__class__.url_+'api/courses/create/'+__CONFIG__['TOKENS']['LECTURER'],data=payload)
|
||||
#r = requests.post('http://localhost:8080/api/courses/create/_QA_TOKEN_TEST_LECTURER',data=payload)
|
||||
#self.assertEquals(r.status_code, 201)
|
||||
|
||||
def test_coursesCreate_InvalidToken(self):
|
||||
headers = {'content-type': 'application/json'}
|
||||
url = self.__class__.url_+'api/courses/create/invalidToken'
|
||||
data = {
|
||||
'courseName': 'QA COURSE',
|
||||
'campusName': 'https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg',
|
||||
'projects': '@gay.lord.ultima.multi.omega',
|
||||
'startDate': {'year': 2015, 'month' : 4, 'day' : 3},
|
||||
'endDate': {'year': 2016,'month' : 6,'day' : 6}
|
||||
}
|
||||
params = {'seToken': 'seToken' }
|
||||
r = requests.post(url, params=params, data=json.dumps(data), headers=headers)
|
||||
self.assertEquals(r.status_code, 403)
|
||||
'''
|
||||
payload = {'courseName': 'Advance Math', 'campusName': 'JCE', 'startDate':'2015-14-3','endDate': '2015-29-6','taskFlag': 'False'}
|
||||
payload = {
|
||||
'courseName': 'QA COURSE',
|
||||
'campusName': 'https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg',
|
||||
'projects': '@gay.lord.ultima.multi.omega',
|
||||
'startDate': {'year': 2015, 'month' : 4, 'day' : 3},
|
||||
'endDate': {'year': 2016,'month' : 6,'day' : 6}
|
||||
}
|
||||
r = requests.post(self.__class__.url_+'api/courses/create/invalidToken',data=payload)
|
||||
self.assertEquals(r.status_code, 403)
|
||||
|
||||
'''
|
||||
def test_coursesCreate_Student(self):
|
||||
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)
|
||||
headers = {'content-type': 'application/json'}
|
||||
url = self.__class__.url_+'api/courses/create/_QA_TOKEN_TEST_STUDENT'
|
||||
params = {'seToken': 'seToken' }
|
||||
data = {
|
||||
'courseName': 'QA COURSE',
|
||||
'campusName': 'https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg',
|
||||
'projects': '@gay.lord.ultima.multi.omega',
|
||||
'startDate': {'year': 2015, 'month' : 4, 'day' : 3},
|
||||
'endDate': {'year': 2016,'month' : 6,'day' : 6}
|
||||
}
|
||||
|
||||
#r = requests.post(self.__class__.url_+'api/courses/create/'+__CONFIG__['TOKENS']['STUDENT'],data=payload)
|
||||
r = requests.post(url, params=params, data=json.dumps(data), headers=headers)
|
||||
self.assertEquals(r.status_code, 403, 'message: ' + r.json()['message'])
|
||||
|
||||
def test_getCourseByCampusName(self):
|
||||
r = requests.get(self.__class__.url_+'api/courses/getCourseByCampusName/'+__CONFIG__['TOKENS']['CAMPUS_NAME'])
|
||||
|
|
|
@ -81,7 +81,7 @@ class UserTestPlan(unittest.TestCase):
|
|||
self.assertEquals(r.json()['campuses_id_list'],[])
|
||||
|
||||
def test_userUpdate_Student(self):
|
||||
payload = {'name': 'New Name', 'isLecturer': 'false'}
|
||||
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 = {}
|
||||
|
|
|
@ -2,7 +2,7 @@ __author__ = 'etye'
|
|||
|
||||
|
||||
__CONFIG__ = {
|
||||
'DEBUG': True,
|
||||
'DEBUG': False,
|
||||
'PATHS': {
|
||||
'DEBUG': 'http://localhost:8080/',
|
||||
'PRODUCTION': 'http://se-hub.appspot.com/'
|
||||
|
|
Loading…
Reference in a new issue