From f25e50862356153a74ada7cdb04172bbdf288653 Mon Sep 17 00:00:00 2001 From: etyemyer Date: Mon, 15 Jun 2015 22:11:46 +0300 Subject: [PATCH] UserApi_Test - test getuserbytoken with valid,invalid and empty string CampusesApi_test - with valid,invalid string --- Testing/CampusAPI_Test.py | 9 ++++---- Testing/UserAPI_Test.py | 44 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 47 insertions(+), 6 deletions(-) diff --git a/Testing/CampusAPI_Test.py b/Testing/CampusAPI_Test.py index d43f62f..09be45d 100644 --- a/Testing/CampusAPI_Test.py +++ b/Testing/CampusAPI_Test.py @@ -15,16 +15,17 @@ class UserTestPlan(unittest.TestCase): if 200 <= request.status_code <= 299: print 'Initialized' - def test_Campuses_invalidToken(self): - r = requests.get(self.__class__.url_+'api/Campuses/invalidtoken') + def test_campusesGet_invalidToken(self): + r = requests.get(self.__class__.url_+'api/campuses/getAll/invalidtoken') self.assertEquals(r.status_code, 403) - def test_Campuses_validToken_testArraySize(self): - r = requests.get(self.__class__.url_+'api/Campuses/'+__CONFIG__['TOKENS']['STUDENT']) + def test_campusesGet_validToken_testArraySize(self): + r = requests.get(self.__class__.url_+'api/campuses/getAll/'+__CONFIG__['TOKENS']['STUDENT']) self.assertEquals(r.status_code, 200) self.assertTrue(len(r.json())>= 1) + if __name__ == '__main__': unittest.main() \ No newline at end of file diff --git a/Testing/UserAPI_Test.py b/Testing/UserAPI_Test.py index e907400..7baa8cb 100644 --- a/Testing/UserAPI_Test.py +++ b/Testing/UserAPI_Test.py @@ -18,7 +18,7 @@ class UserTestPlan(unittest.TestCase): def test_getUserByToken_invalid(self): r = requests.get(self.__class__.url_+'api/users/getUserByToken/invalidtoken') - self.assertEquals(r.status_code, 403) + self.assertEquals(r.status_code, 204) def test_getUserByToken_valid(self): r = requests.get(self.__class__.url_+'api/users/getUserByToken/'+__CONFIG__['TOKENS']['STUDENT']) @@ -27,7 +27,7 @@ class UserTestPlan(unittest.TestCase): def test_getUserByToken_empty(self): r = requests.get(self.__class__.url_+'api/users/getUserByToken/') - self.assertEquals(r.status_code, 400) + self.assertEquals(r.status_code, 204) def test_isStudent_Student(self): r = requests.get(self.__class__.url_+'api/users/getUserByToken/'+__CONFIG__['TOKENS']['STUDENT']) @@ -39,6 +39,46 @@ class UserTestPlan(unittest.TestCase): self.assertEquals(r.status_code, 200) self.assertTrue(r.json()['isLecturer']) + def test_isFirstLogin_Student(self): + r = requests.get(self.__class__.url_+'api/users/getUserByToken/'+__CONFIG__['TOKENS']['STUDENT']) + self.assertEquals(r.status_code, 200) + self.assertTrue(r.json()['isFirstLogin']) + + def test_isFirstLogin_Lecturer(self): + r = requests.get(self.__class__.url_+'api/users/getUserByToken/'+__CONFIG__['TOKENS']['LECTURER']) + self.assertEquals(r.status_code, 200) + self.assertTrue(r.json()['isFirstLogin']) + + def test_isClassIdListEmpty_Student(self): + r = requests.get(self.__class__.url_+'api/users/getUserByToken/'+__CONFIG__['TOKENS']['STUDENT']) + self.assertEquals(r.status_code, 200) + self.assertEquals(r.json()['classes_id_list'],[]) + + def test_campuses_id_list_Student(self): + r = requests.get(self.__class__.url_+'api/users/getUserByToken/'+__CONFIG__['TOKENS']['STUDENT']) + self.assertEquals(r.status_code, 200) + self.assertEquals(r.json()['campuses_id_list'],[]) + + def test_Student_isLecturer(self): + r = requests.get(self.__class__.url_+'api/users/getUserByToken/'+__CONFIG__['TOKENS']['STUDENT']) + self.assertEquals(r.status_code, 200) + self.assertFalse(r.json()['isLecturer']) + + def test_Lecturer_isLecturer(self): + r = requests.get(self.__class__.url_+'api/users/getUserByToken/'+__CONFIG__['TOKENS']['LECTURER']) + self.assertEquals(r.status_code, 200) + self.assertFalse(r.json()['isLecturer']) + + def test_isClassIdListEmpty_Lecturer(self): + r = requests.get(self.__class__.url_+'api/users/getUserByToken/'+__CONFIG__['TOKENS']['LECTURER']) + self.assertEquals(r.status_code, 200) + self.assertEquals(r.json()['classes_id_list'],[]) + + def test_campuses_id_list_Lecturer(self): + 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'],[]) + if __name__ == '__main__': unittest.main() \ No newline at end of file