Merge branch 'master' of github.com:sagidayan/SE-Hub
This commit is contained in:
commit
5a118075c4
5 changed files with 285 additions and 0 deletions
|
@ -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 UserTestPlan(unittest.TestCase):
|
class UserTestPlan(unittest.TestCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -15,6 +16,45 @@ class UserTestPlan(unittest.TestCase):
|
||||||
if 200 <= request.status_code <= 299:
|
if 200 <= request.status_code <= 299:
|
||||||
print 'Initialized'
|
print 'Initialized'
|
||||||
|
|
||||||
|
#/api/campuses/create/<string:token>
|
||||||
|
def test_campusCreate_lecturer(self):
|
||||||
|
#url = "http://localhost:8080/api/courses/create/_QA_TOKEN_TEST_LECTURER"
|
||||||
|
url=self.__class__.url_+'api/campuses/create/'+__CONFIG__['TOKENS']['LECTURER']
|
||||||
|
data = {
|
||||||
|
'title': 'Campus name',
|
||||||
|
'email_ending': '@campus.ac.com',
|
||||||
|
'avatar_url': 'http://location.domain.com/image.jpg'
|
||||||
|
}
|
||||||
|
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
|
||||||
|
r = requests.post(url, data=json.dumps(data), headers=headers)
|
||||||
|
self.assertEquals(r.status_code, 201)
|
||||||
|
|
||||||
|
def test_campusCreate_student(self):
|
||||||
|
#url = "http://localhost:8080/api/courses/create/_QA_TOKEN_TEST_LECTURER"
|
||||||
|
url=self.__class__.url_+'api/campuses/create/'+__CONFIG__['TOKENS']['STUDENT']
|
||||||
|
data = {
|
||||||
|
'title': 'Campus name',
|
||||||
|
'email_ending': '@campus.ac.com',
|
||||||
|
'avatar_url': 'http://location.domain.com/image.jpg'
|
||||||
|
}
|
||||||
|
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
|
||||||
|
r = requests.post(url, data=json.dumps(data), headers=headers)
|
||||||
|
self.assertEquals(r.status_code, 403)
|
||||||
|
self.assertEquals(r._content, '{"message": "Invalid token or not a lecturer!"}')
|
||||||
|
|
||||||
|
def test_campusCreate_invalidToken(self):
|
||||||
|
#url = "http://localhost:8080/api/courses/create/_QA_TOKEN_TEST_LECTURER"
|
||||||
|
url=self.__class__.url_+'api/campuses/create/invalidToken'
|
||||||
|
data = {
|
||||||
|
'title': 'Campus name',
|
||||||
|
'email_ending': '@campus.ac.com',
|
||||||
|
'avatar_url': 'http://location.domain.com/image.jpg'
|
||||||
|
}
|
||||||
|
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
|
||||||
|
r = requests.post(url, data=json.dumps(data), headers=headers)
|
||||||
|
self.assertEquals(r.status_code, 403)
|
||||||
|
self.assertEquals(r._content, '{"message": "Invalid token or not a lecturer!"}')
|
||||||
|
|
||||||
def test_campusesGet_invalidToken(self):
|
def test_campusesGet_invalidToken(self):
|
||||||
r = requests.get(self.__class__.url_+'api/campuses/getAll/invalidtoken')
|
r = requests.get(self.__class__.url_+'api/campuses/getAll/invalidtoken')
|
||||||
self.assertEquals(r.status_code, 403)
|
self.assertEquals(r.status_code, 403)
|
||||||
|
@ -24,6 +64,11 @@ 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_testArraySize(self):
|
||||||
|
r = requests.get(self.__class__.url_+'api/campuses/getAll/'+__CONFIG__['TOKENS']['LECTURER'])
|
||||||
|
self.assertEquals(r.status_code, 200)
|
||||||
|
self.assertTrue(len(r.json())>= 1)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
91
Testing/CoursesAPI_Test.py
Normal file
91
Testing/CoursesAPI_Test.py
Normal file
|
@ -0,0 +1,91 @@
|
||||||
|
__author__ = 'etye'
|
||||||
|
import unittest
|
||||||
|
import requests
|
||||||
|
import json
|
||||||
|
from Testing.config import __CONFIG__
|
||||||
|
class CoursesTestPlan(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'
|
||||||
|
|
||||||
|
def test_coursesCreate_Lecturer(self):
|
||||||
|
headers = {'content-type': 'application/json'}
|
||||||
|
url = 'http://se-hub.appspot.com/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',
|
||||||
|
'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):
|
||||||
|
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': '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)
|
||||||
|
'''
|
||||||
|
def test_coursesCreate_Student(self):
|
||||||
|
headers = {'content-type': 'application/json'}
|
||||||
|
url = self.__class__.url_+'api/courses/create/_QA_TOKEN_TEST_STUDENT'
|
||||||
|
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):
|
||||||
|
r = requests.get(self.__class__.url_+'api/courses/getCourseByCampusName/'+__CONFIG__['TOKENS']['CAMPUS_NAME'])
|
||||||
|
self.assertEquals(r.status_code, 200)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
97
Testing/CoursesAPI_test.py
Normal file
97
Testing/CoursesAPI_test.py
Normal file
|
@ -0,0 +1,97 @@
|
||||||
|
__author__ = 'etye'
|
||||||
|
import unittest
|
||||||
|
import requests
|
||||||
|
import json
|
||||||
|
from Testing.config import __CONFIG__
|
||||||
|
|
||||||
|
class UserTestPlan(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'
|
||||||
|
|
||||||
|
def test_courseCreate_lecturer(self):
|
||||||
|
#url = "http://localhost:8080/api/courses/create/_QA_TOKEN_TEST_LECTURER"
|
||||||
|
url=self.__class__.url_+'api/courses/create/'+__CONFIG__['TOKENS']['LECTURER']
|
||||||
|
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)
|
||||||
|
self.assertEquals(r.status_code, 201)
|
||||||
|
|
||||||
|
def test_courseCreate_lecturerExsistingCourse(self):
|
||||||
|
#url = "http://localhost:8080/api/courses/create/_QA_TOKEN_TEST_LECTURER"
|
||||||
|
url=self.__class__.url_+'api/courses/create/'+__CONFIG__['TOKENS']['LECTURER']
|
||||||
|
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)
|
||||||
|
self.assertEquals(r.status_code, 403)
|
||||||
|
|
||||||
|
def test_courseCreate_student(self):
|
||||||
|
#url = "http://localhost:8080/api/courses/create/_QA_TOKEN_TEST_LECTURER"
|
||||||
|
url=self.__class__.url_+'api/courses/create/'+__CONFIG__['TOKENS']['STUDENT']
|
||||||
|
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)
|
||||||
|
self.assertEquals(r.status_code, 403)
|
||||||
|
|
||||||
|
def test_courseCreate_invalidToken(self):
|
||||||
|
#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)
|
||||||
|
self.assertEquals(r.status_code, 403)
|
||||||
|
|
||||||
|
def test_courseCreate_hebrewToken(self):
|
||||||
|
#url = "http://localhost:8080/api/courses/create/_QA_TOKEN_TEST_LECTURER"
|
||||||
|
url=self.__class__.url_+'api/courses/create/????'
|
||||||
|
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)
|
||||||
|
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)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
|
@ -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 UserTestPlan(unittest.TestCase):
|
class UserTestPlan(unittest.TestCase):
|
||||||
|
@ -79,6 +80,54 @@ class UserTestPlan(unittest.TestCase):
|
||||||
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'],[])
|
||||||
|
|
||||||
|
#/api/users/updateUser/<string:token>
|
||||||
|
|
||||||
|
def test_updateUser_lecturer(self):
|
||||||
|
url=self.__class__.url_+'api/users/updateUser/'+__CONFIG__['TOKENS']['LECTURER']
|
||||||
|
data = {
|
||||||
|
'name': 'new name',
|
||||||
|
'isLecturer': True,
|
||||||
|
'campusName': 'JCE'
|
||||||
|
}
|
||||||
|
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
|
||||||
|
r = requests.post(url, data=json.dumps(data), headers=headers)
|
||||||
|
self.assertEquals(r.status_code, 200)
|
||||||
|
self.assertEquals(r._content, '{"message": "User updated"}')
|
||||||
|
|
||||||
|
def test_updateUser_student(self):
|
||||||
|
url=self.__class__.url_+'api/users/updateUser/'+__CONFIG__['TOKENS']['STUDENT']
|
||||||
|
data = {
|
||||||
|
'name': 'new name',
|
||||||
|
'isLecturer': True,
|
||||||
|
'campusName': 'JCE'
|
||||||
|
}
|
||||||
|
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
|
||||||
|
r = requests.post(url, data=json.dumps(data), headers=headers)
|
||||||
|
self.assertEquals(r.status_code, 200)
|
||||||
|
self.assertEquals(r._content, '{"message": "User updated"}')
|
||||||
|
|
||||||
|
def test_updateUser_INVALID_TOKEN(self):
|
||||||
|
url=self.__class__.url_+'api/users/updateUser/invalidToken'
|
||||||
|
data = {
|
||||||
|
'name': 'new name',
|
||||||
|
'isLecturer': True,
|
||||||
|
'campusName': 'JCE'
|
||||||
|
}
|
||||||
|
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
|
||||||
|
r = requests.post(url, data=json.dumps(data), headers=headers)
|
||||||
|
self.assertEquals(r.status_code, 400)
|
||||||
|
self.assertEquals(r._content, '{"message": "Not a user!"}')
|
||||||
|
|
||||||
|
def test_updateUser_HEBREW_TOKEN(self):
|
||||||
|
url=self.__class__.url_+'api/users/updateUser/?????'
|
||||||
|
data = {
|
||||||
|
'name': 'new name',
|
||||||
|
'isLecturer': True,
|
||||||
|
'campusName': 'JCE'
|
||||||
|
}
|
||||||
|
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
|
||||||
|
r = requests.post(url, data=json.dumps(data), headers=headers)
|
||||||
|
self.assertEquals(r.status_code, 404)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
|
@ -10,5 +10,8 @@ __CONFIG__ = {
|
||||||
'TOKENS':{
|
'TOKENS':{
|
||||||
'STUDENT': '_QA_TOKEN_TEST_STUDENT',
|
'STUDENT': '_QA_TOKEN_TEST_STUDENT',
|
||||||
'LECTURER': '_QA_TOKEN_TEST_LECTURER'
|
'LECTURER': '_QA_TOKEN_TEST_LECTURER'
|
||||||
|
},
|
||||||
|
'CAMPUS_NAME':{
|
||||||
|
'JCE':'JCE'
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue