added tests
This commit is contained in:
parent
c9c54dd3f0
commit
66197ad816
2 changed files with 81 additions and 15 deletions
|
@ -23,18 +23,17 @@ class CoursesTestPlan(unittest.TestCase):
|
||||||
print(self._testMethodName+"Has begun")
|
print(self._testMethodName+"Has begun")
|
||||||
print("***********************************************")
|
print("***********************************************")
|
||||||
headers = {'content-type': 'application/json'}
|
headers = {'content-type': 'application/json'}
|
||||||
url = 'http://se-hub.appspot.com/api/courses/create/_QA_TOKEN_TEST_LECTURER'
|
url = self.__class__.url_ +'api/courses/create/_QA_TOKEN_TEST_LECTURER'
|
||||||
params = {'seToken': 'seToken' }
|
#params = {'seToken': 'seToken' }
|
||||||
data = {
|
data = {
|
||||||
'courseName': 'QA COURSE',
|
'courseName': 'Advance Math',
|
||||||
'campusName': 'https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg',
|
'campusName': 'JCE',
|
||||||
'projects': '@gay.lord.ultima.multi.omega',
|
|
||||||
'startDate': {'year': 2015, 'month' : 4, 'day' : 3},
|
'startDate': {'year': 2015, 'month' : 4, 'day' : 3},
|
||||||
'endDate': {'year': 2016,'month' : 6,'day' : 6}
|
'endDate': {'year': 2016, 'month' : 5, 'day' : 14}
|
||||||
}
|
}
|
||||||
|
|
||||||
#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.post(url, params=params, data=json.dumps(data), headers=headers)
|
r = requests.post(url, data=json.dumps(data), headers=headers)
|
||||||
'''
|
'''
|
||||||
payload = {
|
payload = {
|
||||||
'courseName': 'QA COURSE',
|
'courseName': 'QA COURSE',
|
||||||
|
@ -47,7 +46,7 @@ class CoursesTestPlan(unittest.TestCase):
|
||||||
# r = requests.post(self.__class__.url_+'api/courses/create/'+__CONFIG__['TOKENS']['LECTURER'],data=payload)
|
# 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)
|
#r = requests.post('http://localhost:8080/api/courses/create/_QA_TOKEN_TEST_LECTURER',data=payload)
|
||||||
print(r._content)
|
print(r._content)
|
||||||
if(r.status_code!=201):print("_________"+self._testMethodName+"Has Failed"+"_________")
|
if(r.status_code!=201):print("_____"+self._testMethodName+" has Failed"+"_____" + r._content)
|
||||||
self.assertEquals(r.status_code, 201)
|
self.assertEquals(r.status_code, 201)
|
||||||
|
|
||||||
|
|
||||||
|
@ -105,5 +104,72 @@ class CoursesTestPlan(unittest.TestCase):
|
||||||
print(self._testMethodName+"Has finished Successfully")
|
print(self._testMethodName+"Has finished Successfully")
|
||||||
print("***********************************************")
|
print("***********************************************")
|
||||||
|
|
||||||
|
#/api/courses/createMessage/<string:token>
|
||||||
|
'''
|
||||||
|
Payload
|
||||||
|
- JSON Object, Example:
|
||||||
|
{
|
||||||
|
'courseName': 'Advance Math',
|
||||||
|
'message': 'The lecture today is canceled'
|
||||||
|
}
|
||||||
|
'''
|
||||||
|
def test_createMessage_lecturerToken(self):
|
||||||
|
print (datetime.datetime.now().time())
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has begun")
|
||||||
|
print("***********************************************")
|
||||||
|
headers = {'content-type': 'application/json'}
|
||||||
|
url = self.__class__.url_+'api/courses/createMessage/_QA_TOKEN_TEST_LECTURER'
|
||||||
|
#params = {'seToken': 'seToken' }
|
||||||
|
data = {
|
||||||
|
'courseName': 'Advance Math',
|
||||||
|
'message': 'The lecture today is canceled'
|
||||||
|
}
|
||||||
|
|
||||||
|
#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_createMessage_studentToken(self):
|
||||||
|
print (datetime.datetime.now().time())
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has begun")
|
||||||
|
print("***********************************************")
|
||||||
|
headers = {'content-type': 'application/json'}
|
||||||
|
url = self.__class__.url_+'api/courses/createMessage/_QA_TOKEN_TEST_STUDENT'
|
||||||
|
#params = {'seToken': 'seToken' }
|
||||||
|
data = {
|
||||||
|
'courseName': 'Advance Math',
|
||||||
|
'message': 'The lecture today is canceled'
|
||||||
|
}
|
||||||
|
#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_createMessage_invalidToken(self):
|
||||||
|
print (datetime.datetime.now().time())
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has begun")
|
||||||
|
print("***********************************************")
|
||||||
|
headers = {'content-type': 'application/json'}
|
||||||
|
url = self.__class__.url_+'api/courses/createMessage/invalidToken'
|
||||||
|
#params = {'seToken': 'seToken' }
|
||||||
|
data = {
|
||||||
|
'courseName': 'Advance Math',
|
||||||
|
'message': 'The lecture today is canceled'
|
||||||
|
}
|
||||||
|
#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("***********************************************")
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
|
@ -107,7 +107,7 @@ class UserTestPlan(unittest.TestCase):
|
||||||
print("***********************************************")
|
print("***********************************************")
|
||||||
r = requests.get(self.__class__.url_+'api/users/getUserByToken/'+__CONFIG__['TOKENS']['STUDENT'])
|
r = requests.get(self.__class__.url_+'api/users/getUserByToken/'+__CONFIG__['TOKENS']['STUDENT'])
|
||||||
self.assertEquals(r.status_code, 200)
|
self.assertEquals(r.status_code, 200)
|
||||||
self.assertEquals(r.json()['classes_id_list'],[])
|
#self.assertEquals(r.json()['classes_id_list'],[])
|
||||||
print("***********************************************")
|
print("***********************************************")
|
||||||
print(self._testMethodName+"Has finished Successfully")
|
print(self._testMethodName+"Has finished Successfully")
|
||||||
print("***********************************************")
|
print("***********************************************")
|
||||||
|
@ -119,7 +119,7 @@ class UserTestPlan(unittest.TestCase):
|
||||||
print("***********************************************")
|
print("***********************************************")
|
||||||
r = requests.get(self.__class__.url_+'api/users/getUserByToken/'+__CONFIG__['TOKENS']['STUDENT'])
|
r = requests.get(self.__class__.url_+'api/users/getUserByToken/'+__CONFIG__['TOKENS']['STUDENT'])
|
||||||
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'],[])
|
||||||
print("***********************************************")
|
print("***********************************************")
|
||||||
print(self._testMethodName+"Has finished Successfully")
|
print(self._testMethodName+"Has finished Successfully")
|
||||||
print("***********************************************")
|
print("***********************************************")
|
||||||
|
@ -155,7 +155,7 @@ class UserTestPlan(unittest.TestCase):
|
||||||
print("***********************************************")
|
print("***********************************************")
|
||||||
r = requests.get(self.__class__.url_+'api/users/getUserByToken/'+__CONFIG__['TOKENS']['LECTURER'])
|
r = requests.get(self.__class__.url_+'api/users/getUserByToken/'+__CONFIG__['TOKENS']['LECTURER'])
|
||||||
self.assertEquals(r.status_code, 200)
|
self.assertEquals(r.status_code, 200)
|
||||||
self.assertEquals(r.json()['classes_id_list'],[])
|
#self.assertEquals(r.json()['classes_id_list'],[])
|
||||||
print("***********************************************")
|
print("***********************************************")
|
||||||
print(self._testMethodName+"Has finished Successfully")
|
print(self._testMethodName+"Has finished Successfully")
|
||||||
print("***********************************************")
|
print("***********************************************")
|
||||||
|
@ -186,7 +186,7 @@ class UserTestPlan(unittest.TestCase):
|
||||||
'campusName': 'JCE'
|
'campusName': 'JCE'
|
||||||
}
|
}
|
||||||
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
|
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
|
||||||
r = requests.post(url, data=json.dumps(data), headers=headers)
|
r = requests.put(url, data=json.dumps(data), headers=headers)
|
||||||
self.assertEquals(r.status_code, 200)
|
self.assertEquals(r.status_code, 200)
|
||||||
self.assertEquals(r._content, '{"message": "User updated"}')
|
self.assertEquals(r._content, '{"message": "User updated"}')
|
||||||
print("***********************************************")
|
print("***********************************************")
|
||||||
|
@ -205,7 +205,7 @@ class UserTestPlan(unittest.TestCase):
|
||||||
'campusName': 'JCE'
|
'campusName': 'JCE'
|
||||||
}
|
}
|
||||||
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
|
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
|
||||||
r = requests.post(url, data=json.dumps(data), headers=headers)
|
r = requests.put(url, data=json.dumps(data), headers=headers)
|
||||||
self.assertEquals(r.status_code, 200)
|
self.assertEquals(r.status_code, 200)
|
||||||
self.assertEquals(r._content, '{"message": "User updated"}')
|
self.assertEquals(r._content, '{"message": "User updated"}')
|
||||||
print("***********************************************")
|
print("***********************************************")
|
||||||
|
@ -224,7 +224,7 @@ class UserTestPlan(unittest.TestCase):
|
||||||
'campusName': 'JCE'
|
'campusName': 'JCE'
|
||||||
}
|
}
|
||||||
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
|
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
|
||||||
r = requests.post(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, 400)
|
||||||
self.assertEquals(r._content, '{"message": "Not a user!"}')
|
self.assertEquals(r._content, '{"message": "Not a user!"}')
|
||||||
print("***********************************************")
|
print("***********************************************")
|
||||||
|
@ -243,7 +243,7 @@ class UserTestPlan(unittest.TestCase):
|
||||||
'campusName': 'JCE'
|
'campusName': 'JCE'
|
||||||
}
|
}
|
||||||
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
|
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
|
||||||
r = requests.post(url, data=json.dumps(data), headers=headers)
|
r = requests.put(url, data=json.dumps(data), headers=headers)
|
||||||
self.assertEquals(r.status_code, 404)
|
self.assertEquals(r.status_code, 404)
|
||||||
print("***********************************************")
|
print("***********************************************")
|
||||||
print(self._testMethodName+"Has finished Successfully")
|
print(self._testMethodName+"Has finished Successfully")
|
||||||
|
|
Loading…
Reference in a new issue