From a6c162fc92482f908663cb985af3b51dcc1e3ecf Mon Sep 17 00:00:00 2001 From: etyemyer Date: Mon, 29 Jun 2015 19:24:41 +0300 Subject: [PATCH] Updated User Tests. --- Testing/UserAPI_Test.py | 143 +++++++++++++++++++++++++++++++++++++++- Testing/config.py | 4 ++ 2 files changed, 146 insertions(+), 1 deletion(-) diff --git a/Testing/UserAPI_Test.py b/Testing/UserAPI_Test.py index ec13e09..c76dea8 100644 --- a/Testing/UserAPI_Test.py +++ b/Testing/UserAPI_Test.py @@ -29,6 +29,8 @@ class UserTestPlan(unittest.TestCase): print(self._testMethodName+"Has finished Successfully") print("***********************************************") + + def test_getUserByToken_valid(self): print (datetime.datetime.now().time()) print("***********************************************") @@ -167,7 +169,6 @@ 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()['campuses_id_list'],[]) print("***********************************************") print(self._testMethodName+"Has finished Successfully") print("***********************************************") @@ -249,6 +250,146 @@ class UserTestPlan(unittest.TestCase): print(self._testMethodName+"Has finished Successfully") print("***********************************************") + #/api/users/addUserToCampus/ + def test_addUserToCampus_lecturer(self): + headers = {'content-type': 'application/json'} + url = self.__class__.url_+'api/users/addUserToCampus/'+__CONFIG__['TOKENS']['LECTURER'] + #params = {'seToken': 'seToken' } + data = { + "campusId": 6736157987569664 + } + #r = requests.post(self.__class__.url_+'api/courses/create/'+__CONFIG__['TOKENS']['STUDENT'],data=payload) + r = requests.put(url, data=json.dumps(data), headers=headers) + self.assertEquals(r.status_code, 200) + + def test_addUserToCampus_student(self): + headers = {'content-type': 'application/json'} + url = self.__class__.url_+'api/users/addUserToCampus/'+__CONFIG__['TOKENS']['STUDENT'] + #params = {'seToken': 'seToken' } + data = { + "campusId": 6736157987569664 + } + #r = requests.post(self.__class__.url_+'api/courses/create/'+__CONFIG__['TOKENS']['STUDENT'],data=payload) + r = requests.put(url, data=json.dumps(data), headers=headers) + self.assertEquals(r.status_code, 400) + + def test_addUserToCampus_invalidToken(self): + headers = {'content-type': 'application/json'} + url = self.__class__.url_+'api/users/addUserToCampus/invalidToken' + #params = {'seToken': 'seToken' } + data = { + "campusId": 6736157987569664 + } + #r = requests.post(self.__class__.url_+'api/courses/create/'+__CONFIG__['TOKENS']['STUDENT'],data=payload) + r = requests.put(url, data=json.dumps(data), headers=headers) + self.assertEquals(r.status_code, 400) + + ''' + def test_addUserToCourse_invalidToken(self): + headers = {'content-type': 'application/json'} + url = self.__class__.url_+'api/users/addUserToCourse/invalidToken' + #params = {'seToken': 'seToken' } + data = { + "campusId": 5522297150504960 + } + #r = requests.post(self.__class__.url_+'api/courses/create/'+__CONFIG__['TOKENS']['STUDENT'],data=payload) + r = requests.put(url, data=json.dumps(data), headers=headers) + self.assertEquals(r.status_code, 400) + + def test_addUserToCourse_lecturer(self): + headers = {'content-type': 'application/json'} + url = self.__class__.url_+'api/users/addUserToCampus/'+__CONFIG__['TOKENS']['LECTURER'] + #params = {'seToken': 'seToken' } + data = { + "courseId": 5522297150504960 + } + #r = requests.post(self.__class__.url_+'api/courses/create/'+__CONFIG__['TOKENS']['STUDENT'],data=payload) + r = requests.put(url, data=json.dumps(data), headers=headers) + self.assertEquals(r.status_code, ) +''' + def test_getUserById_student(self): + #url = self.__class__.url_+'api/users/getUserById/'+__CONFIG__['TOKENS']['STUDENT'] + '/'+__CONFIG__['ID']['STUDENT_ID'] + url = 'http://localhost:8080/api/users/getUserById/_QA_TOKEN_TEST_STUDENT/6225984592281600' + r = requests.get(url) + self.assertEquals(r.status_code, 200) + + def test_getUserById_lecturer(self): + #url = self.__class__.url_+'api/users/getUserById/'+__CONFIG__['TOKENS']['STUDENT'] + '/'+__CONFIG__['ID']['STUDENT_ID'] + url = 'http://localhost:8080/api/users/getUserById/_QA_TOKEN_TEST_LECTURER/6225984592281600' + r = requests.get(url) + self.assertEquals(r.status_code, 200) + + def test_getUserById_invalidToken(self): + #url = self.__class__.url_+'api/users/getUserById/'+__CONFIG__['TOKENS']['STUDENT'] + '/'+__CONFIG__['ID']['STUDENT_ID'] + url = 'http://localhost:8080/api/users/getUserById/invalidToken/InvalidId' + r = requests.get(url) + self.assertEquals(r.status_code, 403) + + #/api/users/getUsersByCampus//