Added Tests CoursesApi - course create

UserApi - Fixed tests
This commit is contained in:
etyemyer 2015-06-17 23:18:13 +03:00
parent 02dc0c58ee
commit faad6dae00
3 changed files with 63 additions and 10 deletions

View file

@ -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 CoursesTestPlan(unittest.TestCase): class CoursesTestPlan(unittest.TestCase):
@classmethod @classmethod
@ -16,19 +17,71 @@ class CoursesTestPlan(unittest.TestCase):
print 'Initialized' print 'Initialized'
def test_coursesCreate_Lecturer(self): def test_coursesCreate_Lecturer(self):
payload = {'courseName': 'Advance Math', 'campusName': 'JCE', 'startDate':'2015-14-3','endDate': '2015-29-6','taskFlag': 'False'} headers = {'content-type': 'application/json'}
r = requests.post(self.__class__.url_+'api/courses/create/'+__CONFIG__['TOKENS']['LECTURER'],data=payload) url = 'http://se-hub.appspot.com/api/courses/create/_QA_TOKEN_TEST_LECTURER'
self.assertEquals(r.status_code, 201) 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): 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': '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) r = requests.post(self.__class__.url_+'api/courses/create/invalidToken',data=payload)
self.assertEquals(r.status_code, 403) '''
def test_coursesCreate_Student(self): def test_coursesCreate_Student(self):
payload = {'courseName': 'Advance Math', 'campusName': 'JCE', 'startDate':'2015-14-3','endDate': '2015-29-6','taskFlag': 'False'} headers = {'content-type': 'application/json'}
r = requests.post(self.__class__.url_+'api/courses/create/'+__CONFIG__['TOKENS']['STUDENT'],data=payload) url = self.__class__.url_+'api/courses/create/_QA_TOKEN_TEST_STUDENT'
self.assertEquals(r.status_code, 403) 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): def test_getCourseByCampusName(self):
r = requests.get(self.__class__.url_+'api/courses/getCourseByCampusName/'+__CONFIG__['TOKENS']['CAMPUS_NAME']) r = requests.get(self.__class__.url_+'api/courses/getCourseByCampusName/'+__CONFIG__['TOKENS']['CAMPUS_NAME'])

View file

@ -81,7 +81,7 @@ class UserTestPlan(unittest.TestCase):
self.assertEquals(r.json()['campuses_id_list'],[]) self.assertEquals(r.json()['campuses_id_list'],[])
def test_userUpdate_Student(self): 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) r = requests.post(self.__class__.url_+'api/users/userUpdate/'+__CONFIG__['TOKENS']['STUDENT'],data=payload)
self.assertEquals(r.status_code, 200) self.assertEquals(r.status_code, 200)
#data = {} #data = {}

View file

@ -2,7 +2,7 @@ __author__ = 'etye'
__CONFIG__ = { __CONFIG__ = {
'DEBUG': True, 'DEBUG': False,
'PATHS': { 'PATHS': {
'DEBUG': 'http://localhost:8080/', 'DEBUG': 'http://localhost:8080/',
'PRODUCTION': 'http://se-hub.appspot.com/' 'PRODUCTION': 'http://se-hub.appspot.com/'