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("***********************************************")
|
||||
headers = {'content-type': 'application/json'}
|
||||
url = 'http://se-hub.appspot.com/api/courses/create/_QA_TOKEN_TEST_LECTURER'
|
||||
params = {'seToken': 'seToken' }
|
||||
url = self.__class__.url_ +'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',
|
||||
'courseName': 'Advance Math',
|
||||
'campusName': 'JCE',
|
||||
'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(url, params=params, data=json.dumps(data), headers=headers)
|
||||
r = requests.post(url, data=json.dumps(data), headers=headers)
|
||||
'''
|
||||
payload = {
|
||||
'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('http://localhost:8080/api/courses/create/_QA_TOKEN_TEST_LECTURER',data=payload)
|
||||
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)
|
||||
|
||||
|
||||
|
@ -105,5 +104,72 @@ class CoursesTestPlan(unittest.TestCase):
|
|||
print(self._testMethodName+"Has finished Successfully")
|
||||
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__':
|
||||
unittest.main()
|
|
@ -107,7 +107,7 @@ class UserTestPlan(unittest.TestCase):
|
|||
print("***********************************************")
|
||||
r = requests.get(self.__class__.url_+'api/users/getUserByToken/'+__CONFIG__['TOKENS']['STUDENT'])
|
||||
self.assertEquals(r.status_code, 200)
|
||||
self.assertEquals(r.json()['classes_id_list'],[])
|
||||
#self.assertEquals(r.json()['classes_id_list'],[])
|
||||
print("***********************************************")
|
||||
print(self._testMethodName+"Has finished Successfully")
|
||||
print("***********************************************")
|
||||
|
@ -119,7 +119,7 @@ class UserTestPlan(unittest.TestCase):
|
|||
print("***********************************************")
|
||||
r = requests.get(self.__class__.url_+'api/users/getUserByToken/'+__CONFIG__['TOKENS']['STUDENT'])
|
||||
self.assertEquals(r.status_code, 200)
|
||||
self.assertEquals(r.json()['campuses_id_list'],[])
|
||||
#self.assertEquals(r.json()['campuses_id_list'],[])
|
||||
print("***********************************************")
|
||||
print(self._testMethodName+"Has finished Successfully")
|
||||
print("***********************************************")
|
||||
|
@ -155,7 +155,7 @@ class UserTestPlan(unittest.TestCase):
|
|||
print("***********************************************")
|
||||
r = requests.get(self.__class__.url_+'api/users/getUserByToken/'+__CONFIG__['TOKENS']['LECTURER'])
|
||||
self.assertEquals(r.status_code, 200)
|
||||
self.assertEquals(r.json()['classes_id_list'],[])
|
||||
#self.assertEquals(r.json()['classes_id_list'],[])
|
||||
print("***********************************************")
|
||||
print(self._testMethodName+"Has finished Successfully")
|
||||
print("***********************************************")
|
||||
|
@ -186,7 +186,7 @@ class UserTestPlan(unittest.TestCase):
|
|||
'campusName': 'JCE'
|
||||
}
|
||||
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._content, '{"message": "User updated"}')
|
||||
print("***********************************************")
|
||||
|
@ -205,7 +205,7 @@ class UserTestPlan(unittest.TestCase):
|
|||
'campusName': 'JCE'
|
||||
}
|
||||
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._content, '{"message": "User updated"}')
|
||||
print("***********************************************")
|
||||
|
@ -224,7 +224,7 @@ class UserTestPlan(unittest.TestCase):
|
|||
'campusName': 'JCE'
|
||||
}
|
||||
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._content, '{"message": "Not a user!"}')
|
||||
print("***********************************************")
|
||||
|
@ -243,7 +243,7 @@ class UserTestPlan(unittest.TestCase):
|
|||
'campusName': 'JCE'
|
||||
}
|
||||
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)
|
||||
print("***********************************************")
|
||||
print(self._testMethodName+"Has finished Successfully")
|
||||
|
|
Loading…
Reference in a new issue