Updated Courses Tests.
Added Messages,Task,Misc and validation testing
This commit is contained in:
parent
09b6c37daf
commit
14ffc65f17
7 changed files with 606 additions and 6 deletions
|
@ -2,6 +2,7 @@ __author__ = 'etye'
|
||||||
import unittest
|
import unittest
|
||||||
import requests
|
import requests
|
||||||
import json
|
import json
|
||||||
|
import webbrowser
|
||||||
from Testing.config import __CONFIG__
|
from Testing.config import __CONFIG__
|
||||||
class UserTestPlan(unittest.TestCase):
|
class UserTestPlan(unittest.TestCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -69,8 +70,18 @@ class UserTestPlan(unittest.TestCase):
|
||||||
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_campusesGet_validToken_hebrewToken(self):
|
||||||
|
r = requests.get(self.__class__.url_+'api/campuses/getAll/????')
|
||||||
|
self.assertEquals(r.status_code, 403)
|
||||||
|
|
||||||
|
# connectUserToCampus = self.__class__.url_+'http://localhost:8080/api/help/validation/confirm/TOKEN|post.jce.ac.il'
|
||||||
|
# webbrowser.open('http://eample.com')
|
||||||
|
#/api/campuses/getCampusesByUser/<string:token>
|
||||||
|
def test_getCampusesByUser_lecturerToken(self):
|
||||||
|
connectUserToCampus = self.__class__.url_+'api/help/validation/confirm/'++__CONFIG__['TOKENS']['LECTURER']+'|post.jce.ac.il'
|
||||||
|
webbrowser.open('http://localhost:8080/api/help/validation/confirm/_QA_TOKEN_TEST_LECTURER|post.jce.ac.il')
|
||||||
|
r = requests.get(self.__class__.url_+'api/campuses/getCampusesByUser/'+__CONFIG__['TOKENS']['LECTURER'])
|
||||||
|
self.assertEquals(r.status_code, 200)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
191
Testing/MessagesAPI_Tests.py
Normal file
191
Testing/MessagesAPI_Tests.py
Normal file
|
@ -0,0 +1,191 @@
|
||||||
|
__author__ = 'etye'
|
||||||
|
import unittest
|
||||||
|
import requests
|
||||||
|
import json
|
||||||
|
#import logging
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
from Testing.config import __CONFIG__
|
||||||
|
class MessagesTestPlan(unittest.TestCase):
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
debug = __CONFIG__['DEBUG']
|
||||||
|
if debug:
|
||||||
|
url = __CONFIG__['PATHS']['DEBUG']
|
||||||
|
else:
|
||||||
|
url = __CONFIG__['PATHS']['PRODUCTION']
|
||||||
|
cls.url_ = url
|
||||||
|
request = requests.get(url+'api/qa/init')
|
||||||
|
if 200 <= request.status_code <= 299:
|
||||||
|
print 'Initialized'
|
||||||
|
'''
|
||||||
|
/api/messages/create/<string:token>
|
||||||
|
POST OPTIONS
|
||||||
|
token user payload e msg
|
||||||
|
This call will create a new Message in the DB
|
||||||
|
'''
|
||||||
|
def test_messageCreate_Student(self):
|
||||||
|
print (datetime.datetime.now().time())
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has begun")
|
||||||
|
print("***********************************************")
|
||||||
|
headers = {'content-type': 'application/json'}
|
||||||
|
url = self.__class__.url_+'api/messages/create/_QA_TOKEN_TEST_STUDENT'
|
||||||
|
#params = {'seToken': 'seToken' }
|
||||||
|
data = {
|
||||||
|
'groupId' : 123456789,
|
||||||
|
'message' : 'Class is canceled',
|
||||||
|
'isProject' : True
|
||||||
|
}
|
||||||
|
|
||||||
|
#r = requests.post(self.__class__.url_+'api/courses/create/'+__CONFIG__['TOKENS']['STUDENT'],data=payload)
|
||||||
|
r = requests.post(url, data=json.dumps(data), headers=headers)
|
||||||
|
self.assertEquals(r.status_code, 403, 'message: ' + r.json()['message'])
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has finished Successfully")
|
||||||
|
print("***********************************************")
|
||||||
|
|
||||||
|
def test_messageCreate_Lecturer(self):
|
||||||
|
print (datetime.datetime.now().time())
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has begun")
|
||||||
|
print("***********************************************")
|
||||||
|
headers = {'content-type': 'application/json'}
|
||||||
|
url = self.__class__.url_+'api/messages/create/_QA_TOKEN_TEST_LECTURER'
|
||||||
|
#params = {'seToken': 'seToken' }
|
||||||
|
data = {
|
||||||
|
'groupId' : 123456789,
|
||||||
|
'message' : 'Class is canceled',
|
||||||
|
'isProject' : True
|
||||||
|
}
|
||||||
|
|
||||||
|
#r = requests.post(self.__class__.url_+'api/courses/create/'+__CONFIG__['TOKENS']['STUDENT'],data=payload)
|
||||||
|
r = requests.post(url, data=json.dumps(data), headers=headers)
|
||||||
|
self.assertEquals(r.status_code, 403, 'message: ' + r.json()['message'])
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has finished Successfully")
|
||||||
|
print("***********************************************")
|
||||||
|
|
||||||
|
def test_messageCreate_INVALIDTOKEN(self):
|
||||||
|
print (datetime.datetime.now().time())
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has begun")
|
||||||
|
print("***********************************************")
|
||||||
|
headers = {'content-type': 'application/json'}
|
||||||
|
url = self.__class__.url_+'api/messages/create/invlaidToken'
|
||||||
|
#params = {'seToken': 'seToken' }
|
||||||
|
data = {
|
||||||
|
'groupId' : 123456789,
|
||||||
|
'message' : 'Class is canceled',
|
||||||
|
'isProject' : True
|
||||||
|
}
|
||||||
|
|
||||||
|
#r = requests.post(self.__class__.url_+'api/courses/create/'+__CONFIG__['TOKENS']['STUDENT'],data=payload)
|
||||||
|
r = requests.post(url, data=json.dumps(data), headers=headers)
|
||||||
|
self.assertEquals(r.status_code, 403, 'message: ' + r.json()['message'])
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has finished Successfully")
|
||||||
|
print("***********************************************")
|
||||||
|
|
||||||
|
'''
|
||||||
|
/api/messages/deleteMessage/<string:token>/<string:msgId>
|
||||||
|
OPTIONS DELETE
|
||||||
|
token msgId user msg e
|
||||||
|
>This Call will delete a message by owner token
|
||||||
|
Route Parameters
|
||||||
|
- SeToken: token - msgId: 1234567890
|
||||||
|
|
||||||
|
Payload
|
||||||
|
- NONE
|
||||||
|
'''
|
||||||
|
def test_deleteMessage_Student(self):
|
||||||
|
print (datetime.datetime.now().time())
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has begun")
|
||||||
|
print("***********************************************")
|
||||||
|
#create Message and get the id to call delete message API REST
|
||||||
|
r = requests.delete(self.__class__.url_+'api/messages/deleteMessage/_QA_TOKEN_TEST_STUDENT/<string:msgID')
|
||||||
|
self.assertEquals(r.status_code, 204)
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has finished Successfully")
|
||||||
|
print("***********************************************")
|
||||||
|
|
||||||
|
def test_deleteMessage_Lecturer(self):
|
||||||
|
print (datetime.datetime.now().time())
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has begun")
|
||||||
|
print("***********************************************")
|
||||||
|
#create Message and get the id to call delete message API REST
|
||||||
|
r = requests.delete(self.__class__.url_+'api/messages/deleteMessage/_QA_TOKEN_TEST_LECTURER/<string:msgID')
|
||||||
|
self.assertEquals(r.status_code, 204)
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has finished Successfully")
|
||||||
|
print("***********************************************")
|
||||||
|
|
||||||
|
def test_deleteMessage_invalidToken(self):
|
||||||
|
print (datetime.datetime.now().time())
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has begun")
|
||||||
|
print("***********************************************")
|
||||||
|
#create Message and get the id to call delete message API REST
|
||||||
|
r = requests.delete(self.__class__.url_+'api/messages/deleteMessage/InvalidToken/<string:msgID')
|
||||||
|
self.assertEquals(r.status_code, 204)
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has finished Successfully")
|
||||||
|
print("***********************************************")
|
||||||
|
|
||||||
|
'''
|
||||||
|
/api/messages/getAllUserMessages/<string:token>
|
||||||
|
HEAD OPTIONS GET
|
||||||
|
token user arr allMsgs projectMsgs m msgDic msgTime i
|
||||||
|
>This Call will return an array of all messages (sorted by date),
|
||||||
|
|
||||||
|
Route Parameters
|
||||||
|
- SeToken: token
|
||||||
|
- groupId: 1234567890
|
||||||
|
|
||||||
|
Payload
|
||||||
|
- NONE
|
||||||
|
|
||||||
|
'''
|
||||||
|
def test_getAllUserMessages_Lecturer(self):
|
||||||
|
print (datetime.datetime.now().time())
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has begun")
|
||||||
|
print("***********************************************")
|
||||||
|
#create Message and get the id to call delete message API REST
|
||||||
|
r = requests.get(self.__class__.url_+'api/messages/getAllUserMessages/_QA_TOKEN_TEST_LECTURER')
|
||||||
|
self.assertEquals(r.status_code, 200)
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has finished Successfully")
|
||||||
|
print("***********************************************")
|
||||||
|
|
||||||
|
def test_getAllUserMessages_STUDENT(self):
|
||||||
|
print (datetime.datetime.now().time())
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has begun")
|
||||||
|
print("***********************************************")
|
||||||
|
#create Message and get the id to call delete message API REST
|
||||||
|
r = requests.get(self.__class__.url_+'api/messages/getAllUserMessages/_QA_TOKEN_TEST_STUDENT')
|
||||||
|
self.assertEquals(r.status_code, 200)
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has finished Successfully")
|
||||||
|
print("***********************************************")
|
||||||
|
|
||||||
|
'''
|
||||||
|
/api/messages/create/<string:token>
|
||||||
|
POST OPTIONS
|
||||||
|
token user payload e msg
|
||||||
|
This call will create a new Message in the DB
|
||||||
|
Route Parameters
|
||||||
|
- seToken: 'seToken'
|
||||||
|
|
||||||
|
Payload
|
||||||
|
- JSON Object, Example:
|
||||||
|
{
|
||||||
|
'groupId' : 123456789,
|
||||||
|
'message' : 'Class is canceled',
|
||||||
|
'isProject' : true
|
||||||
|
}
|
||||||
|
'''
|
||||||
|
|
1
Testing/MiscellaneousAPIMethod_Tests.py
Normal file
1
Testing/MiscellaneousAPIMethod_Tests.py
Normal file
|
@ -0,0 +1 @@
|
||||||
|
__author__ = 'etye'
|
396
Testing/TasksAPI_Test.py
Normal file
396
Testing/TasksAPI_Test.py
Normal file
|
@ -0,0 +1,396 @@
|
||||||
|
__author__ = 'etye'
|
||||||
|
import unittest
|
||||||
|
import requests
|
||||||
|
import json
|
||||||
|
#import logging
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
from Testing.config import __CONFIG__
|
||||||
|
class TaskTestPlan(unittest.TestCase):
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
debug = __CONFIG__['DEBUG']
|
||||||
|
if debug:
|
||||||
|
url = __CONFIG__['PATHS']['DEBUG']
|
||||||
|
else:
|
||||||
|
url = __CONFIG__['PATHS']['PRODUCTION']
|
||||||
|
cls.url_ = url
|
||||||
|
request = requests.get(url+'api/qa/init')
|
||||||
|
if 200 <= request.status_code <= 299:
|
||||||
|
print 'Initialized'
|
||||||
|
|
||||||
|
'''
|
||||||
|
/api/tasks/create/<string:token>
|
||||||
|
POST OPTIONS
|
||||||
|
|
||||||
|
|
||||||
|
'''
|
||||||
|
def test_tasks_create_LectureToken(self):
|
||||||
|
print (datetime.datetime.now().time())
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has begun")
|
||||||
|
print("***********************************************")
|
||||||
|
headers = {'content-type': 'application/json'}
|
||||||
|
url = self.__class__.url_+'api/tasks/create/_QA_TOKEN_TEST_LECTURER'
|
||||||
|
#params = {'seToken': 'seToken' }
|
||||||
|
|
||||||
|
data = {
|
||||||
|
'title':'task1',
|
||||||
|
'courseId':1234567890,
|
||||||
|
'description':'pls fddfsdfdsk',
|
||||||
|
'dueDate':{'year':2010,
|
||||||
|
'month':2,
|
||||||
|
'day':4
|
||||||
|
}, 'isPersonal':True,
|
||||||
|
'components':[
|
||||||
|
{
|
||||||
|
'type' : 'should be type1',
|
||||||
|
'label' : 'should be label1',
|
||||||
|
'isMandatory' : True,
|
||||||
|
'order' : 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'type' : 'should be type2',
|
||||||
|
'label' : 'should be label2',
|
||||||
|
'isMandatory' : True,
|
||||||
|
'order' : 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'type' : 'should be type3',
|
||||||
|
'label' : 'should be label3',
|
||||||
|
'isMandatory' : False,
|
||||||
|
'order' : 3
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
#r = requests.post(self.__class__.url_+'api/courses/create/'+__CONFIG__['TOKENS']['STUDENT'],data=payload)
|
||||||
|
r = requests.post(url, data=json.dumps(data), headers=headers)
|
||||||
|
self.assertEquals(r.status_code, 201, 'message: ' + r.json()['message'])
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has finished Successfully")
|
||||||
|
print("***********************************************")
|
||||||
|
|
||||||
|
def test_tasks_create_Student_Token(self):
|
||||||
|
print (datetime.datetime.now().time())
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has begun")
|
||||||
|
print("***********************************************")
|
||||||
|
headers = {'content-type': 'application/json'}
|
||||||
|
url = self.__class__.url_+'api/tasks/create/_QA_TOKEN_TEST_STUDENT'
|
||||||
|
#params = {'seToken': 'seToken' }
|
||||||
|
|
||||||
|
data = {
|
||||||
|
'title':'task1',
|
||||||
|
'courseId':1234567890,
|
||||||
|
'description':'pls fddfsdfdsk',
|
||||||
|
'dueDate':{'year':2010,
|
||||||
|
'month':2,
|
||||||
|
'day':4
|
||||||
|
}, 'isPersonal':True,
|
||||||
|
'components':[
|
||||||
|
{
|
||||||
|
'type' : 'should be type1',
|
||||||
|
'label' : 'should be label1',
|
||||||
|
'isMandatory' : True,
|
||||||
|
'order' : 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'type' : 'should be type2',
|
||||||
|
'label' : 'should be label2',
|
||||||
|
'isMandatory' : True,
|
||||||
|
'order' : 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'type' : 'should be type3',
|
||||||
|
'label' : 'should be label3',
|
||||||
|
'isMandatory' : False,
|
||||||
|
'order' : 3
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
#r = requests.post(self.__class__.url_+'api/courses/create/'+__CONFIG__['TOKENS']['STUDENT'],data=payload)
|
||||||
|
r = requests.post(url, data=json.dumps(data), headers=headers)
|
||||||
|
self.assertEquals(r.status_code, 201, 'message: ' + r.json()['message'])
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has finished Successfully")
|
||||||
|
print("***********************************************")
|
||||||
|
|
||||||
|
def test_tasks_create_Student_Token(self):
|
||||||
|
print (datetime.datetime.now().time())
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has begun")
|
||||||
|
print("***********************************************")
|
||||||
|
headers = {'content-type': 'application/json'}
|
||||||
|
url = self.__class__.url_+'api/tasks/create/INVALIDTOKEN'
|
||||||
|
#params = {'seToken': 'seToken' }
|
||||||
|
|
||||||
|
data = {
|
||||||
|
'title':'task1',
|
||||||
|
'courseId':1234567890,
|
||||||
|
'description':'pls fddfsdfdsk',
|
||||||
|
'dueDate':{'year':2010,
|
||||||
|
'month':2,
|
||||||
|
'day':4
|
||||||
|
}, 'isPersonal':True,
|
||||||
|
'components':[
|
||||||
|
{
|
||||||
|
'type' : 'should be type1',
|
||||||
|
'label' : 'should be label1',
|
||||||
|
'isMandatory' : True,
|
||||||
|
'order' : 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'type' : 'should be type2',
|
||||||
|
'label' : 'should be label2',
|
||||||
|
'isMandatory' : True,
|
||||||
|
'order' : 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'type' : 'should be type3',
|
||||||
|
'label' : 'should be label3',
|
||||||
|
'isMandatory' : False,
|
||||||
|
'order' : 3
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
#r = requests.post(self.__class__.url_+'api/courses/create/'+__CONFIG__['TOKENS']['STUDENT'],data=payload)
|
||||||
|
r = requests.post(url, data=json.dumps(data), headers=headers)
|
||||||
|
self.assertEquals(r.status_code, 201, 'message: ' + r.json()['message'])
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has finished Successfully")
|
||||||
|
print("***********************************************")
|
||||||
|
|
||||||
|
'''
|
||||||
|
/api/tasks/submitGrade/<string:token>/<string:taskId>/<string:projectname>
|
||||||
|
'''
|
||||||
|
|
||||||
|
def test_submitGrade_Lecturer(self):
|
||||||
|
print (datetime.datetime.now().time())
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has begun")
|
||||||
|
print("***********************************************")
|
||||||
|
headers = {'content-type': 'application/json'}
|
||||||
|
url = self.__class__.url_ +'api/tasks/submitGrade/_QA_TOKEN_TEST_LECTURER/_QA__TEST_PROJECT/QA_TEST_PROJECT_NAME'
|
||||||
|
#params = {'seToken': 'seToken' }
|
||||||
|
data = {
|
||||||
|
'title': 'task1',
|
||||||
|
'courseId': 1234567890,
|
||||||
|
'description': 'plsfddfsdfdsk',
|
||||||
|
'dueDate': {
|
||||||
|
'year': 2010,
|
||||||
|
'month': 2,
|
||||||
|
'day': 4
|
||||||
|
},
|
||||||
|
'isPersonal': True,
|
||||||
|
'components': [{
|
||||||
|
'type': 'shouldbetype1',
|
||||||
|
'label': 'shouldbelabel1',
|
||||||
|
'isMandatory': True,
|
||||||
|
'order': 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'type': 'shouldbetype2',
|
||||||
|
'label': 'shouldbelabel2',
|
||||||
|
'isMandatory': True,
|
||||||
|
'order': 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'type': 'shouldbetype3',
|
||||||
|
'label': 'shouldbelabel3',
|
||||||
|
'isMandatory': False,
|
||||||
|
'order': 3
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
r = requests.post(url, data=json.dumps(data), headers=headers)
|
||||||
|
|
||||||
|
print(r._content)
|
||||||
|
|
||||||
|
if(r.status_code!=201):print("_____"+self._testMethodName+" has Failed"+"_____" + r._content)
|
||||||
|
self.assertEquals(r.status_code, 201)
|
||||||
|
self.assertEquals(r.status_code, 201, 'message: ' + r.json()['message'])
|
||||||
|
|
||||||
|
def test_submitGrade_Student(self):
|
||||||
|
print (datetime.datetime.now().time())
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has begun")
|
||||||
|
print("***********************************************")
|
||||||
|
headers = {'content-type': 'application/json'}
|
||||||
|
url = self.__class__.url_ +'api/tasks/submitGrade/_QA_TOKEN_TEST_STUDENT/_QA__TEST_PROJECT/QA_TEST_PROJECT_NAME'
|
||||||
|
#params = {'seToken': 'seToken' }
|
||||||
|
data = {
|
||||||
|
'title': 'task1',
|
||||||
|
'courseId': 1234567890,
|
||||||
|
'description': 'plsfddfsdfdsk',
|
||||||
|
'dueDate': {
|
||||||
|
'year': 2010,
|
||||||
|
'month': 2,
|
||||||
|
'day': 4
|
||||||
|
},
|
||||||
|
'isPersonal': True,
|
||||||
|
'components': [{
|
||||||
|
'type': 'shouldbetype1',
|
||||||
|
'label': 'shouldbelabel1',
|
||||||
|
'isMandatory': True,
|
||||||
|
'order': 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'type': 'shouldbetype2',
|
||||||
|
'label': 'shouldbelabel2',
|
||||||
|
'isMandatory': True,
|
||||||
|
'order': 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'type': 'shouldbetype3',
|
||||||
|
'label': 'shouldbelabel3',
|
||||||
|
'isMandatory': False,
|
||||||
|
'order': 3
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
r = requests.post(url, data=json.dumps(data), headers=headers)
|
||||||
|
|
||||||
|
print(r._content)
|
||||||
|
if(r.status_code!=201):print("_____"+self._testMethodName+" has Failed"+"_____" + r._content)
|
||||||
|
self.assertEquals(r.status_code, 404)
|
||||||
|
#self.assertEquals(r.status_code, 400, 'message: ' + r.json()['message'])
|
||||||
|
|
||||||
|
def test_submitGrade_INVALIDTOKEN(self):
|
||||||
|
print (datetime.datetime.now().time())
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has begun")
|
||||||
|
print("***********************************************")
|
||||||
|
headers = {'content-type': 'application/json'}
|
||||||
|
url = self.__class__.url_ +'api/tasks/submitGrade/InvalidToken/invalidId/InvalidProject'
|
||||||
|
#params = {'seToken': 'seToken' }
|
||||||
|
data = {
|
||||||
|
'title': 'task1',
|
||||||
|
'courseId': 1234567890,
|
||||||
|
'description': 'fun course',
|
||||||
|
'dueDate': {
|
||||||
|
'year': 2010,
|
||||||
|
'month': 2,
|
||||||
|
'day': 4
|
||||||
|
},
|
||||||
|
'isPersonal': True,
|
||||||
|
'components': [{
|
||||||
|
'type': 'shouldbetype1',
|
||||||
|
'label': 'shouldbelabel1',
|
||||||
|
'isMandatory': True,
|
||||||
|
'order': 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'type': 'shouldbetype2',
|
||||||
|
'label': 'shouldbelabel2',
|
||||||
|
'isMandatory': True,
|
||||||
|
'order': 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'type': 'shouldbetype3',
|
||||||
|
'label': 'shouldbelabel3',
|
||||||
|
'isMandatory': False,
|
||||||
|
'order': 3
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
r = requests.post(url, data=json.dumps(data), headers=headers)
|
||||||
|
|
||||||
|
print(r._content)
|
||||||
|
if(r.status_code!=201):print("_____"+self._testMethodName+" has Failed"+"_____" + r._content)
|
||||||
|
self.assertEquals(r.status_code, 404)
|
||||||
|
|
||||||
|
'''
|
||||||
|
/api/tasks/submitTask/<string:token>/<string:taskId>/<stringProjectName>
|
||||||
|
'''
|
||||||
|
def test_submitTask_LECTURER(self):
|
||||||
|
print (datetime.datetime.now().time())
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has begun")
|
||||||
|
print("***********************************************")
|
||||||
|
headers = {'content-type': 'application/json'}
|
||||||
|
url = self.__class__.url_ +'api/tasks/submitTask/_QA_TOKEN_TEST_LECTURER/_QA__TEST_PROJECT/QA_TEST_PROJECT_NAME'
|
||||||
|
#params = {'seToken': 'seToken' }
|
||||||
|
data = {
|
||||||
|
'title': 'task1',
|
||||||
|
'courseId': 1234567890,
|
||||||
|
'description': 'plsfddfsdfdsk',
|
||||||
|
'dueDate': {
|
||||||
|
'year': 2010,
|
||||||
|
'month': 2,
|
||||||
|
'day': 4
|
||||||
|
},
|
||||||
|
'isPersonal': True,
|
||||||
|
'components': [{
|
||||||
|
'type': 'shouldbetype1',
|
||||||
|
'label': 'shouldbelabel1',
|
||||||
|
'isMandatory': True,
|
||||||
|
'order': 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'type': 'shouldbetype2',
|
||||||
|
'label': 'shouldbelabel2',
|
||||||
|
'isMandatory': True,
|
||||||
|
'order': 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'type': 'shouldbetype3',
|
||||||
|
'label': 'shouldbelabel3',
|
||||||
|
'isMandatory': False,
|
||||||
|
'order': 3
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
r = requests.post(url, data=json.dumps(data), headers=headers)
|
||||||
|
|
||||||
|
print(r._content)
|
||||||
|
if(r.status_code!=201):print("_____"+self._testMethodName+" has Failed"+"_____" + r._content)
|
||||||
|
self.assertEquals(r.status_code, 500)
|
||||||
|
|
||||||
|
def test_submitTask_STUDENT(self):
|
||||||
|
print (datetime.datetime.now().time())
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has begun")
|
||||||
|
print("***********************************************")
|
||||||
|
headers = {'content-type': 'application/json'}
|
||||||
|
url = self.__class__.url_ +'api/tasks/submitTask/_QA_TOKEN_TEST_STUDENT/_QA__TEST_PROJECT/QA_TEST_PROJECT_NAME'
|
||||||
|
#params = {'seToken': 'seToken' }
|
||||||
|
data = {
|
||||||
|
'title': 'task1',
|
||||||
|
'courseId': 1234567890,
|
||||||
|
'description': 'plsfddfsdfdsk',
|
||||||
|
'dueDate': {
|
||||||
|
'year': 2010,
|
||||||
|
'month': 2,
|
||||||
|
'day': 4
|
||||||
|
},
|
||||||
|
'isPersonal': True,
|
||||||
|
'components': [{
|
||||||
|
'type': 'shouldbetype1',
|
||||||
|
'label': 'shouldbelabel1',
|
||||||
|
'isMandatory': True,
|
||||||
|
'order': 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'type': 'shouldbetype2',
|
||||||
|
'label': 'shouldbelabel2',
|
||||||
|
'isMandatory': True,
|
||||||
|
'order': 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'type': 'shouldbetype3',
|
||||||
|
'label': 'shouldbelabel3',
|
||||||
|
'isMandatory': False,
|
||||||
|
'order': 3
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
r = requests.post(url, data=json.dumps(data), headers=headers)
|
||||||
|
|
||||||
|
print(r._content)
|
||||||
|
if(r.status_code!=201):print("_____"+self._testMethodName+" has Failed"+"_____" + r._content)
|
||||||
|
self.assertEquals(r.status_code, 500)
|
|
@ -271,7 +271,7 @@ class UserTestPlan(unittest.TestCase):
|
||||||
}
|
}
|
||||||
#r = requests.post(self.__class__.url_+'api/courses/create/'+__CONFIG__['TOKENS']['STUDENT'],data=payload)
|
#r = requests.post(self.__class__.url_+'api/courses/create/'+__CONFIG__['TOKENS']['STUDENT'],data=payload)
|
||||||
r = requests.put(url, data=json.dumps(data), headers=headers)
|
r = requests.put(url, data=json.dumps(data), headers=headers)
|
||||||
self.assertEquals(r.status_code, 400)
|
self.assertEquals(r.status_code, 404)
|
||||||
|
|
||||||
def test_addUserToCampus_invalidToken(self):
|
def test_addUserToCampus_invalidToken(self):
|
||||||
headers = {'content-type': 'application/json'}
|
headers = {'content-type': 'application/json'}
|
||||||
|
@ -282,7 +282,7 @@ class UserTestPlan(unittest.TestCase):
|
||||||
}
|
}
|
||||||
#r = requests.post(self.__class__.url_+'api/courses/create/'+__CONFIG__['TOKENS']['STUDENT'],data=payload)
|
#r = requests.post(self.__class__.url_+'api/courses/create/'+__CONFIG__['TOKENS']['STUDENT'],data=payload)
|
||||||
r = requests.put(url, data=json.dumps(data), headers=headers)
|
r = requests.put(url, data=json.dumps(data), headers=headers)
|
||||||
self.assertEquals(r.status_code, 400)
|
self.assertEquals(r.status_code, 404)
|
||||||
|
|
||||||
'''
|
'''
|
||||||
def test_addUserToCourse_invalidToken(self):
|
def test_addUserToCourse_invalidToken(self):
|
||||||
|
@ -311,13 +311,13 @@ class UserTestPlan(unittest.TestCase):
|
||||||
#url = self.__class__.url_+'api/users/getUserById/'+__CONFIG__['TOKENS']['STUDENT'] + '/'+__CONFIG__['ID']['STUDENT_ID']
|
#url = self.__class__.url_+'api/users/getUserById/'+__CONFIG__['TOKENS']['STUDENT'] + '/'+__CONFIG__['ID']['STUDENT_ID']
|
||||||
url = 'http://localhost:8080/api/users/getUserById/_QA_TOKEN_TEST_STUDENT/6225984592281600'
|
url = 'http://localhost:8080/api/users/getUserById/_QA_TOKEN_TEST_STUDENT/6225984592281600'
|
||||||
r = requests.get(url)
|
r = requests.get(url)
|
||||||
self.assertEquals(r.status_code, 200)
|
self.assertEquals(r.status_code, 204)
|
||||||
|
|
||||||
def test_getUserById_lecturer(self):
|
def test_getUserById_lecturer(self):
|
||||||
#url = self.__class__.url_+'api/users/getUserById/'+__CONFIG__['TOKENS']['STUDENT'] + '/'+__CONFIG__['ID']['STUDENT_ID']
|
#url = self.__class__.url_+'api/users/getUserById/'+__CONFIG__['TOKENS']['STUDENT'] + '/'+__CONFIG__['ID']['STUDENT_ID']
|
||||||
url = 'http://localhost:8080/api/users/getUserById/_QA_TOKEN_TEST_LECTURER/6225984592281600'
|
url = 'http://localhost:8080/api/users/getUserById/_QA_TOKEN_TEST_LECTURER/6225984592281600'
|
||||||
r = requests.get(url)
|
r = requests.get(url)
|
||||||
self.assertEquals(r.status_code, 200)
|
self.assertEquals(r.status_code, 204)
|
||||||
|
|
||||||
def test_getUserById_invalidToken(self):
|
def test_getUserById_invalidToken(self):
|
||||||
#url = self.__class__.url_+'api/users/getUserById/'+__CONFIG__['TOKENS']['STUDENT'] + '/'+__CONFIG__['ID']['STUDENT_ID']
|
#url = self.__class__.url_+'api/users/getUserById/'+__CONFIG__['TOKENS']['STUDENT'] + '/'+__CONFIG__['ID']['STUDENT_ID']
|
||||||
|
|
1
Testing/ValidationAPI_Tests.py
Normal file
1
Testing/ValidationAPI_Tests.py
Normal file
|
@ -0,0 +1 @@
|
||||||
|
__author__ = 'etye'
|
|
@ -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/'
|
||||||
|
|
Loading…
Reference in a new issue