Updated tests and added deleted tests
This commit is contained in:
parent
89c16b8ecc
commit
1f74a88db1
4 changed files with 301 additions and 55 deletions
|
@ -21,13 +21,13 @@ class UserTestPlan(unittest.TestCase):
|
||||||
#url = "http://localhost:8080/api/courses/create/_QA_TOKEN_TEST_LECTURER"
|
#url = "http://localhost:8080/api/courses/create/_QA_TOKEN_TEST_LECTURER"
|
||||||
url=self.__class__.url_+'api/campuses/create/'+__CONFIG__['TOKENS']['LECTURER']
|
url=self.__class__.url_+'api/campuses/create/'+__CONFIG__['TOKENS']['LECTURER']
|
||||||
data = {
|
data = {
|
||||||
'title': 'Campus name',
|
'title': 'QA Campus',
|
||||||
'email_ending': '@campus.ac.com',
|
'email_ending': '@campus.ac.com',
|
||||||
'avatar_url': 'http://location.domain.com/image.jpg'
|
'avatar_url': 'http://location.domain.com/image.jpg'
|
||||||
}
|
}
|
||||||
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.post(url, data=json.dumps(data), headers=headers)
|
||||||
self.assertEquals(r.status_code, 201)
|
self.assertEquals(r.status_code, 200)
|
||||||
|
|
||||||
def test_campusCreate_student(self):
|
def test_campusCreate_student(self):
|
||||||
#url = "http://localhost:8080/api/courses/create/_QA_TOKEN_TEST_LECTURER"
|
#url = "http://localhost:8080/api/courses/create/_QA_TOKEN_TEST_LECTURER"
|
||||||
|
|
|
@ -2,9 +2,9 @@ __author__ = 'etye'
|
||||||
import unittest
|
import unittest
|
||||||
import requests
|
import requests
|
||||||
import json
|
import json
|
||||||
|
import datetime
|
||||||
from Testing.config import __CONFIG__
|
from Testing.config import __CONFIG__
|
||||||
|
class CoursesTestPlan(unittest.TestCase):
|
||||||
class UserTestPlan(unittest.TestCase):
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
debug = __CONFIG__['DEBUG']
|
debug = __CONFIG__['DEBUG']
|
||||||
|
@ -17,81 +17,93 @@ class UserTestPlan(unittest.TestCase):
|
||||||
if 200 <= request.status_code <= 299:
|
if 200 <= request.status_code <= 299:
|
||||||
print 'Initialized'
|
print 'Initialized'
|
||||||
|
|
||||||
def test_courseCreate_lecturer(self):
|
def test_coursesCreate_Lecturer(self):
|
||||||
#url = "http://localhost:8080/api/courses/create/_QA_TOKEN_TEST_LECTURER"
|
print (datetime.datetime.now().time())
|
||||||
url=self.__class__.url_+'api/courses/create/'+__CONFIG__['TOKENS']['LECTURER']
|
print("***********************************************")
|
||||||
|
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' }
|
||||||
data = {
|
data = {
|
||||||
'courseName': 'matan',
|
'courseName': 'QA COURSE',
|
||||||
'campusName': 'https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg',
|
'campusName': 'https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg',
|
||||||
'projects': '@gay.lord.ultima.multi.omega',
|
'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' : 6,'day' : 6}
|
||||||
}
|
}
|
||||||
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
|
|
||||||
r = requests.post(url, data=json.dumps(data), headers=headers)
|
#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)
|
||||||
|
print(r._content)
|
||||||
|
if(r.status_code!=201):print("_________"+self._testMethodName+"Has Failed"+"_________")
|
||||||
self.assertEquals(r.status_code, 201)
|
self.assertEquals(r.status_code, 201)
|
||||||
|
|
||||||
def test_courseCreate_lecturerExsistingCourse(self):
|
|
||||||
#url = "http://localhost:8080/api/courses/create/_QA_TOKEN_TEST_LECTURER"
|
def test_coursesCreate_InvalidToken(self):
|
||||||
url=self.__class__.url_+'api/courses/create/'+__CONFIG__['TOKENS']['LECTURER']
|
print (datetime.datetime.now().time())
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has begun")
|
||||||
|
print("***********************************************")
|
||||||
|
headers = {'content-type': 'application/json'}
|
||||||
|
url = self.__class__.url_+'api/courses/create/invalidToken'
|
||||||
data = {
|
data = {
|
||||||
'courseName': 'matan',
|
'courseName': 'QA COURSE',
|
||||||
'campusName': 'https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg',
|
'campusName': 'https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg',
|
||||||
'projects': '@gay.lord.ultima.multi.omega',
|
'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' : 6,'day' : 6}
|
||||||
}
|
}
|
||||||
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
|
|
||||||
r = requests.post(url, data=json.dumps(data), headers=headers)
|
r = requests.post(url, data=json.dumps(data), headers=headers)
|
||||||
self.assertEquals(r.status_code, 403)
|
self.assertEquals(r.status_code, 403)
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has finished Successfully")
|
||||||
|
print("***********************************************")
|
||||||
|
|
||||||
def test_courseCreate_student(self):
|
def test_coursesCreate_Student(self):
|
||||||
#url = "http://localhost:8080/api/courses/create/_QA_TOKEN_TEST_LECTURER"
|
print (datetime.datetime.now().time())
|
||||||
url=self.__class__.url_+'api/courses/create/'+__CONFIG__['TOKENS']['STUDENT']
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has begun")
|
||||||
|
print("***********************************************")
|
||||||
|
headers = {'content-type': 'application/json'}
|
||||||
|
url = self.__class__.url_+'api/courses/create/_QA_TOKEN_TEST_STUDENT'
|
||||||
|
#params = {'seToken': 'seToken' }
|
||||||
data = {
|
data = {
|
||||||
'courseName': 'matan',
|
'courseName': 'QA COURSE',
|
||||||
'campusName': 'https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg',
|
'campusName': 'https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg',
|
||||||
'projects': '@gay.lord.ultima.multi.omega',
|
'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' : 6,'day' : 6}
|
||||||
}
|
}
|
||||||
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
|
|
||||||
r = requests.post(url, data=json.dumps(data), headers=headers)
|
|
||||||
self.assertEquals(r.status_code, 403)
|
|
||||||
|
|
||||||
def test_courseCreate_invalidToken(self):
|
#r = requests.post(self.__class__.url_+'api/courses/create/'+__CONFIG__['TOKENS']['STUDENT'],data=payload)
|
||||||
#url = "http://localhost:8080/api/courses/create/_QA_TOKEN_TEST_LECTURER"
|
|
||||||
url=self.__class__.url_+'api/courses/create/invalidToken'
|
|
||||||
data = {
|
|
||||||
'courseName': 'matan',
|
|
||||||
'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}
|
|
||||||
}
|
|
||||||
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
|
|
||||||
r = requests.post(url, data=json.dumps(data), headers=headers)
|
r = requests.post(url, data=json.dumps(data), headers=headers)
|
||||||
self.assertEquals(r.status_code, 403)
|
self.assertEquals(r.status_code, 403, 'message: ' + r.json()['message'])
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has finished Successfully")
|
||||||
|
print("***********************************************")
|
||||||
|
|
||||||
def test_courseCreate_hebrewToken(self):
|
def test_getCourseByCampusName(self):
|
||||||
#url = "http://localhost:8080/api/courses/create/_QA_TOKEN_TEST_LECTURER"
|
print (datetime.datetime.now().time())
|
||||||
url=self.__class__.url_+'api/courses/create/????'
|
print("***********************************************")
|
||||||
data = {
|
print(self._testMethodName+"Has begun")
|
||||||
'courseName': 'matan',
|
print("***********************************************")
|
||||||
'campusName': 'https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg',
|
r = requests.get(self.__class__.url_+'api/courses/getCourseByCampusName/JCE')
|
||||||
'projects': '@gay.lord.ultima.multi.omega',
|
|
||||||
'startDate': {'year': 2015, 'month' : 4, 'day' : 3},
|
|
||||||
'endDate': {'year': 2016,'month' : 6,'day' : 6}
|
|
||||||
}
|
|
||||||
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
|
|
||||||
r = requests.post(url, data=json.dumps(data), headers=headers)
|
|
||||||
self.assertEquals(r.status_code, 404)
|
|
||||||
|
|
||||||
#/api/courses/getCourseByCampusName/<string:name>
|
|
||||||
def test_getCourseByCampusName_EXSISTING_CAMPUS(self):
|
|
||||||
url=self.__class__.url_+'api/courses/getCourseByCampusName/'+__CONFIG__['CAMPUS_NAME']['JCE']
|
|
||||||
r = requests.get(url)
|
|
||||||
self.assertEquals(r.status_code, 200)
|
self.assertEquals(r.status_code, 200)
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has finished Successfully")
|
||||||
|
print("***********************************************")
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
112
Testing/ProjectAPI_Test.py
Normal file
112
Testing/ProjectAPI_Test.py
Normal file
|
@ -0,0 +1,112 @@
|
||||||
|
__author__ = 'etye'
|
||||||
|
import unittest
|
||||||
|
import requests
|
||||||
|
import json
|
||||||
|
#import logging
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
from Testing.config import __CONFIG__
|
||||||
|
class ProjectTestPlan(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/projects/create/<string:token>
|
||||||
|
def test_projectCreate_lecturerToken(self):
|
||||||
|
print (datetime.datetime.now().time())
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has begun")
|
||||||
|
print("***********************************************")
|
||||||
|
headers = {'content-type': 'application/json'}
|
||||||
|
url = self.__class__.url_+'api/projects/create/'+__CONFIG__['TOKENS']['LECTURER']
|
||||||
|
data = {
|
||||||
|
'projectName': 'Advance Math',
|
||||||
|
'courseName': 'JCE',
|
||||||
|
'logo_url': 'http://location.domain.com/image.jpg',
|
||||||
|
'gitRepository': 'http://location.git.com/somthing'
|
||||||
|
}
|
||||||
|
|
||||||
|
r = requests.post(url, data=json.dumps(data), headers=headers)
|
||||||
|
self.assertEquals(r.status_code, 201)
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has finished")
|
||||||
|
#print("Test Project Create w/ Lecturer token has finished")
|
||||||
|
print("***********************************************")
|
||||||
|
|
||||||
|
|
||||||
|
def test_projectCreate_studentToken(self):
|
||||||
|
print (datetime.datetime.now().time())
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has begun")
|
||||||
|
print("***********************************************")
|
||||||
|
headers = {'content-type': 'application/json'}
|
||||||
|
url = self.__class__.url_+'api/projects/create/'+__CONFIG__['TOKENS']['STUDENT']
|
||||||
|
data = {
|
||||||
|
'projectName': 'Advance Math',
|
||||||
|
'courseName': 'JCE',
|
||||||
|
'logo_url': 'http://location.domain.com/image.jpg',
|
||||||
|
'gitRepository': 'http://location.git.com/somthing'
|
||||||
|
}
|
||||||
|
r = requests.post(url, data=json.dumps(data), headers=headers)
|
||||||
|
self.assertEquals(r.status_code, 403)
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has finished")
|
||||||
|
#print("Test Project Create w/ Lecturer token has finished")
|
||||||
|
print("***********************************************")
|
||||||
|
|
||||||
|
#/api/projects/deleteProject/<string:token>/<string:projectid>
|
||||||
|
def test_projectDelete_studentToken(self):
|
||||||
|
print (datetime.datetime.now().time())
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has begun")
|
||||||
|
print("***********************************************")
|
||||||
|
headers = {'content-type': 'application/json'}
|
||||||
|
url = self.__class__.url_+'api/projects/create/'+__CONFIG__['TOKENS']['STUDENT']
|
||||||
|
r = requests.delete(url)
|
||||||
|
self.assertEquals(r.status_code, 403)
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has finished")
|
||||||
|
#print("Test Project Create w/ Lecturer token has finished")
|
||||||
|
print("***********************************************")
|
||||||
|
|
||||||
|
def test_projectDelete_lecturerToken(self):
|
||||||
|
print (datetime.datetime.now().time())
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has begun")
|
||||||
|
print("***********************************************")
|
||||||
|
headers = {'content-type': 'application/json'}
|
||||||
|
headers = {'content-type': 'application/json'}
|
||||||
|
url = self.__class__.url_+'api/projects/create/'+__CONFIG__['TOKENS']['STUDENT']
|
||||||
|
r = requests.delete(url)
|
||||||
|
self.assertEquals(r.status_code, 403)
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has finished")
|
||||||
|
#print("Test Project Create w/ Lecturer token has finished")
|
||||||
|
print("***********************************************")
|
||||||
|
|
||||||
|
def test_projectDelete_invalidToken(self):
|
||||||
|
print (datetime.datetime.now().time())
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has begun")
|
||||||
|
print("***********************************************")
|
||||||
|
headers = {'content-type': 'application/json'}
|
||||||
|
url = self.__class__.url_+'api/projects/create/'+__CONFIG__['TOKENS']['STUDENT']
|
||||||
|
r = requests.delete(url)
|
||||||
|
self.assertEquals(r.status_code, 403)
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has finished Successfully")
|
||||||
|
#print("Test Project Create w/ Lecturer token has finished")
|
||||||
|
print("***********************************************")
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
suite = unittest.TestLoader().loadTestsFromTestCase(ProjectTestPlan)
|
||||||
|
unittest.TextTestRunner(verbosity=2).run(suite)
|
||||||
|
#unittest.main()
|
|
@ -2,6 +2,7 @@ __author__ = 'etye'
|
||||||
import unittest
|
import unittest
|
||||||
import requests
|
import requests
|
||||||
import json
|
import json
|
||||||
|
import datetime
|
||||||
from Testing.config import __CONFIG__
|
from Testing.config import __CONFIG__
|
||||||
|
|
||||||
class UserTestPlan(unittest.TestCase):
|
class UserTestPlan(unittest.TestCase):
|
||||||
|
@ -18,71 +19,166 @@ class UserTestPlan(unittest.TestCase):
|
||||||
print 'Initialized'
|
print 'Initialized'
|
||||||
|
|
||||||
def test_getUserByToken_invalid(self):
|
def test_getUserByToken_invalid(self):
|
||||||
|
print (datetime.datetime.now().time())
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has begun")
|
||||||
|
print("***********************************************")
|
||||||
r = requests.get(self.__class__.url_+'api/users/getUserByToken/invalidtoken')
|
r = requests.get(self.__class__.url_+'api/users/getUserByToken/invalidtoken')
|
||||||
self.assertEquals(r.status_code, 204)
|
self.assertEquals(r.status_code, 204)
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has finished Successfully")
|
||||||
|
print("***********************************************")
|
||||||
|
|
||||||
def test_getUserByToken_valid(self):
|
def test_getUserByToken_valid(self):
|
||||||
|
print (datetime.datetime.now().time())
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has begun")
|
||||||
|
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()['username'], 'qa_student')
|
self.assertEquals(r.json()['username'], 'qa_student')
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has finished Successfully")
|
||||||
|
print("***********************************************")
|
||||||
|
|
||||||
def test_getUserByToken_empty(self):
|
def test_getUserByToken_empty(self):
|
||||||
|
print (datetime.datetime.now().time())
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has begun")
|
||||||
|
print("***********************************************")
|
||||||
r = requests.get(self.__class__.url_+'api/users/getUserByToken/')
|
r = requests.get(self.__class__.url_+'api/users/getUserByToken/')
|
||||||
self.assertEquals(r.status_code, 204)
|
self.assertEquals(r.status_code, 204)
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has finished Successfully")
|
||||||
|
print("***********************************************")
|
||||||
|
|
||||||
def test_isStudent_Student(self):
|
def test_isStudent_Student(self):
|
||||||
|
print (datetime.datetime.now().time())
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has begun")
|
||||||
|
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.assertFalse(r.json()['isLecturer'])
|
self.assertFalse(r.json()['isLecturer'])
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has finished Successfully")
|
||||||
|
print("***********************************************")
|
||||||
|
|
||||||
def test_isLecturer_Lecturer(self):
|
def test_isLecturer_Lecturer(self):
|
||||||
|
print (datetime.datetime.now().time())
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has begun")
|
||||||
|
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.assertTrue(r.json()['isLecturer'])
|
self.assertTrue(r.json()['isLecturer'])
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has finished Successfully")
|
||||||
|
print("***********************************************")
|
||||||
|
|
||||||
def test_isFirstLogin_Student(self):
|
def test_isFirstLogin_Student(self):
|
||||||
|
print (datetime.datetime.now().time())
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has begun")
|
||||||
|
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.assertTrue(r.json()['isFirstLogin'])
|
self.assertTrue(r.json()['isFirstLogin'])
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has finished Successfully")
|
||||||
|
print("***********************************************")
|
||||||
|
|
||||||
def test_isFirstLogin_Lecturer(self):
|
def test_isFirstLogin_Lecturer(self):
|
||||||
|
print (datetime.datetime.now().time())
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has begun")
|
||||||
|
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.assertTrue(r.json()['isFirstLogin'])
|
self.assertTrue(r.json()['isFirstLogin'])
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has finished Successfully")
|
||||||
|
print("***********************************************")
|
||||||
|
|
||||||
def test_isClassIdListEmpty_Student(self):
|
def test_isClassIdListEmpty_Student(self):
|
||||||
|
print (datetime.datetime.now().time())
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has begun")
|
||||||
|
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(self._testMethodName+"Has finished Successfully")
|
||||||
|
print("***********************************************")
|
||||||
|
|
||||||
def test_campuses_id_list_Student(self):
|
def test_campuses_id_list_Student(self):
|
||||||
|
print (datetime.datetime.now().time())
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has begun")
|
||||||
|
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(self._testMethodName+"Has finished Successfully")
|
||||||
|
print("***********************************************")
|
||||||
|
|
||||||
def test_Student_isLecturer(self):
|
def test_Student_isLecturer(self):
|
||||||
|
print (datetime.datetime.now().time())
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has begun")
|
||||||
|
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.assertFalse(r.json()['isLecturer'])
|
self.assertFalse(r.json()['isLecturer'])
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has finished Successfully")
|
||||||
|
print("***********************************************")
|
||||||
|
|
||||||
def test_Lecturer_isLecturer(self):
|
def test_Lecturer_isLecturer(self):
|
||||||
|
print (datetime.datetime.now().time())
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has begun")
|
||||||
|
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.assertTrue(r.json()['isLecturer'])
|
self.assertTrue(r.json()['isLecturer'])
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has finished Successfully")
|
||||||
|
print("***********************************************")
|
||||||
|
|
||||||
def test_isClassIdListEmpty_Lecturer(self):
|
def test_isClassIdListEmpty_Lecturer(self):
|
||||||
|
print (datetime.datetime.now().time())
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has begun")
|
||||||
|
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(self._testMethodName+"Has finished Successfully")
|
||||||
|
print("***********************************************")
|
||||||
|
|
||||||
def test_campuses_id_list_Lecturer(self):
|
def test_campuses_id_list_Lecturer(self):
|
||||||
|
print (datetime.datetime.now().time())
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has begun")
|
||||||
|
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()['campuses_id_list'],[])
|
self.assertEquals(r.json()['campuses_id_list'],[])
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has finished Successfully")
|
||||||
|
print("***********************************************")
|
||||||
|
|
||||||
#/api/users/updateUser/<string:token>
|
#/api/users/updateUser/<string:token>
|
||||||
|
|
||||||
def test_updateUser_lecturer(self):
|
def test_updateUser_lecturer(self):
|
||||||
|
print (datetime.datetime.now().time())
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has begun")
|
||||||
|
print("***********************************************")
|
||||||
url=self.__class__.url_+'api/users/updateUser/'+__CONFIG__['TOKENS']['LECTURER']
|
url=self.__class__.url_+'api/users/updateUser/'+__CONFIG__['TOKENS']['LECTURER']
|
||||||
data = {
|
data = {
|
||||||
'name': 'new name',
|
'name': 'new name',
|
||||||
|
@ -93,8 +189,15 @@ class UserTestPlan(unittest.TestCase):
|
||||||
r = requests.post(url, data=json.dumps(data), headers=headers)
|
r = requests.post(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(self._testMethodName+"Has finished Successfully")
|
||||||
|
print("***********************************************")
|
||||||
|
|
||||||
def test_updateUser_student(self):
|
def test_updateUser_student(self):
|
||||||
|
print (datetime.datetime.now().time())
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has begun")
|
||||||
|
print("***********************************************")
|
||||||
url=self.__class__.url_+'api/users/updateUser/'+__CONFIG__['TOKENS']['STUDENT']
|
url=self.__class__.url_+'api/users/updateUser/'+__CONFIG__['TOKENS']['STUDENT']
|
||||||
data = {
|
data = {
|
||||||
'name': 'new name',
|
'name': 'new name',
|
||||||
|
@ -105,8 +208,15 @@ class UserTestPlan(unittest.TestCase):
|
||||||
r = requests.post(url, data=json.dumps(data), headers=headers)
|
r = requests.post(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(self._testMethodName+"Has finished Successfully")
|
||||||
|
print("***********************************************")
|
||||||
|
|
||||||
def test_updateUser_INVALID_TOKEN(self):
|
def test_updateUser_INVALID_TOKEN(self):
|
||||||
|
print (datetime.datetime.now().time())
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has begun")
|
||||||
|
print("***********************************************")
|
||||||
url=self.__class__.url_+'api/users/updateUser/invalidToken'
|
url=self.__class__.url_+'api/users/updateUser/invalidToken'
|
||||||
data = {
|
data = {
|
||||||
'name': 'new name',
|
'name': 'new name',
|
||||||
|
@ -117,8 +227,15 @@ class UserTestPlan(unittest.TestCase):
|
||||||
r = requests.post(url, data=json.dumps(data), headers=headers)
|
r = requests.post(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(self._testMethodName+"Has finished Successfully")
|
||||||
|
print("***********************************************")
|
||||||
|
|
||||||
def test_updateUser_HEBREW_TOKEN(self):
|
def test_updateUser_HEBREW_TOKEN(self):
|
||||||
|
print (datetime.datetime.now().time())
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has begun")
|
||||||
|
print("***********************************************")
|
||||||
url=self.__class__.url_+'api/users/updateUser/?????'
|
url=self.__class__.url_+'api/users/updateUser/?????'
|
||||||
data = {
|
data = {
|
||||||
'name': 'new name',
|
'name': 'new name',
|
||||||
|
@ -128,6 +245,11 @@ class UserTestPlan(unittest.TestCase):
|
||||||
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.post(url, data=json.dumps(data), headers=headers)
|
||||||
self.assertEquals(r.status_code, 404)
|
self.assertEquals(r.status_code, 404)
|
||||||
|
print("***********************************************")
|
||||||
|
print(self._testMethodName+"Has finished Successfully")
|
||||||
|
print("***********************************************")
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
suite = unittest.TestLoader().loadTestsFromTestCase(UserTestPlan)
|
||||||
|
unittest.TextTestRunner(verbosity=2).run(suite)
|
||||||
|
#unittest.main()
|
Loading…
Reference in a new issue