UserApi_Test - test getuserbytoken with valid,invalid and empty string

CampusesApi_test -  with valid,invalid string
This commit is contained in:
etyemyer 2015-06-14 23:45:09 +03:00
parent 9ea00145f9
commit aaa5ba223a
2 changed files with 13 additions and 9 deletions

View file

@ -3,7 +3,8 @@ import unittest
import requests import requests
from Testing.config import __CONFIG__ from Testing.config import __CONFIG__
class UserTestPlan(unittest.TestCase): class UserTestPlan(unittest.TestCase):
def setUpClass(cls): @classmethod
def setUpClass(cls):
debug = __CONFIG__['DEBUG'] debug = __CONFIG__['DEBUG']
if debug: if debug:
url = __CONFIG__['PATHS']['DEBUG'] url = __CONFIG__['PATHS']['DEBUG']
@ -14,13 +15,16 @@ class UserTestPlan(unittest.TestCase):
if 200 <= request.status_code <= 299: if 200 <= request.status_code <= 299:
print 'Initialized' print 'Initialized'
def test_Campuses_invalid(self): def test_Campuses_invalidToken(self):
r = requests.get(self.__class__.url_+'api/Campuses/invalidtoken') r = requests.get(self.__class__.url_+'api/Campuses/invalidtoken')
self.assertEquals(r.status_code, 403) self.assertEquals(r.status_code, 403)
def test_Campuses_valid(self):
r = requests.get(self.__class__.url_+'api/Campuses/'+__CONFIG__['TOKENS']['STUDENT']) def test_Campuses_validToken_testArraySize(self):
self.assertEquals(r.status_code, 200) r = requests.get(self.__class__.url_+'api/Campuses/'+__CONFIG__['TOKENS']['STUDENT'])
self.assertEquals(r.json()['username'], 'qa_student') self.assertEquals(r.status_code, 200)
self.assertTrue(len(r.json())>= 1)
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()