Merge pull request #22 from sagidayan/QA
UserApi_Test - test getuserbytoken with valid,invalid and empty string
This commit is contained in:
commit
e7825a1c58
4 changed files with 78 additions and 0 deletions
26
Testing/CampusAPI_Test.py
Normal file
26
Testing/CampusAPI_Test.py
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
__author__ = 'etye'
|
||||||
|
import unittest
|
||||||
|
import requests
|
||||||
|
from Testing.config import __CONFIG__
|
||||||
|
class UserTestPlan(unittest.TestCase):
|
||||||
|
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_Campuses_invalid(self):
|
||||||
|
r = requests.get(self.__class__.url_+'api/Campuses/invalidtoken')
|
||||||
|
self.assertEquals(r.status_code, 403)
|
||||||
|
def test_Campuses_valid(self):
|
||||||
|
r = requests.get(self.__class__.url_+'api/Campuses/'+__CONFIG__['TOKENS']['STUDENT'])
|
||||||
|
self.assertEquals(r.status_code, 200)
|
||||||
|
self.assertEquals(r.json()['username'], 'qa_student')
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
37
Testing/UserAPI_Test.py
Normal file
37
Testing/UserAPI_Test.py
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
__author__ = 'etye'
|
||||||
|
import unittest
|
||||||
|
import requests
|
||||||
|
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_getUserByToken_invalid(self):
|
||||||
|
r = requests.get(self.__class__.url_+'api/getUserByToken/invalidtoken')
|
||||||
|
self.assertEquals(r.status_code, 403)
|
||||||
|
|
||||||
|
|
||||||
|
def test_getUserByToken_valid(self):
|
||||||
|
r = requests.get(self.__class__.url_+'api/getUserByToken/'+__CONFIG__['TOKENS']['STUDENT'])
|
||||||
|
self.assertEquals(r.status_code, 200)
|
||||||
|
self.assertEquals(r.json()['username'], 'qa_student')
|
||||||
|
|
||||||
|
|
||||||
|
def test_getUserByToken_empty(self):
|
||||||
|
r = requests.get(self.__class__.url_+'api/getUserByToken/')
|
||||||
|
self.assertEquals(r.status_code, 400)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
1
Testing/__init__.py
Normal file
1
Testing/__init__.py
Normal file
|
@ -0,0 +1 @@
|
||||||
|
__author__ = 'etye'
|
14
Testing/config.py
Normal file
14
Testing/config.py
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
__author__ = 'etye'
|
||||||
|
|
||||||
|
|
||||||
|
__CONFIG__ = {
|
||||||
|
'DEBUG': True,
|
||||||
|
'PATHS': {
|
||||||
|
'DEBUG': 'http://localhost:8080/',
|
||||||
|
'PRODUCTION': 'http://se-hub.appspot.com/'
|
||||||
|
},
|
||||||
|
'TOKENS':{
|
||||||
|
'STUDENT': '_QA_TOKEN_TEST_STUDENT',
|
||||||
|
'LECTURER': '_QA_TOKEN_TEST_LECTURER'
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue