def test_logout_for_valid_user(self): Test_Start() LOGOUT_TEST_TEXT = 'You have been logged out' uname = USERNAME_FOR_TEST pw = PASSWORD_FOR_TEST smc = SMSCODE_FOR_TEST output = [] post_url = '/accounts/logout/' post_parameters = {} look_for_this = LOGOUT_TEST_TEXT calling_test_function = inspect.getframeinfo(inspect.currentframe().f_back)[2] result = login_to_hive(uname, pw, smc) if result==200: Test_Msg(" Successful login result for: "+uname+"/"+pw+"("+smc+"):"+ str(result)) else: Test_Msg(" Failed login Result - "+str(result)+" using: "+uname+"/"+pw+"("+smc+")") Test_Msg("Now Test Logout: "+post_url) outcome = test_for_200_with_get(self, uname, pw, output, post_url,post_parameters, look_for_this, calling_test_function ) if outcome==None: Test_Msg("Successful Logout to "+post_url) Test_End() return
def test_intake_base_page_for_tester(self): """ Testing for login on home page by tester account """ Test_Start() self.client = Client() self.client.login(username=USERNAME_FOR_TEST,password=PASSWORD_FOR_TEST) attempt_login = login_to_hive(USERNAME_FOR_TEST, PASSWORD_FOR_TEST,SMSCODE_FOR_TEST) print "login result:"+str(attempt_login) Test_Msg("Login to Hive returned:"+str(attempt_login)+" \n for User:"******" "+user_account.last_name # print response result = self.assertContains(response,who_is_logged_in) if result==None: print "result:"+str(result)+" Login Succeeded" else: print "result:"+str(result)+" Login Failed" Test_End() return
def test_get_record_for_invalid_pat_id_with_tester(self): """ GET completed should return a response Tester should have access but with an invalid pat_id """ Test_Start() prn_info = False # We should search for this p = get_object_or_404(PatientProfile, patient_id=VALID_PATIENT_ID) if prn_info!=False: print p self.client = Client() self.client.login(username=USERNAME_FOR_TEST,password=PASSWORD_FOR_TEST) attempt_login = login_to_hive(USERNAME_FOR_TEST, PASSWORD_FOR_TEST,SMSCODE_FOR_TEST) print "login result:"+str(attempt_login) print "get /intake/locator/"+INVALID_PATIENT_ID response = self.client.get('/intake/locator/'+INVALID_PATIENT_ID,follow=True) got_code = self.assertEqual(response.status_code, 404) # print response.content # check response details print "%s = %s" % (response.status_code,'404') Test_Msg("Checked for INVALID_PATIENT_ID in\n /intake/locator/"+INVALID_PATIENT_ID+"\n and got Expected 404") Test_End() return
def test_get_record_for_valid_pat_id_with_non_tester(self): """ GET completed should return a response Non Tester should not have access """ Test_Start() prn_info = False # We should search for this p = get_object_or_404(PatientProfile, patient_id=VALID_PATIENT_ID) if prn_info!=False: print p self.client = Client() self.client.login(username=USERNAME_NOT_TEST,password=PASSWORD_NOT_TEST) attempt_login = login_to_hive(USERNAME_NOT_TEST,PASSWORD_NOT_TEST,SMSCODE_NOT_TEST) print "login result:"+str(attempt_login) print "get /intake/locator/"+VALID_PATIENT_ID response = self.client.get('/intake/locator/'+VALID_PATIENT_ID,follow=True) got_code = self.assertEqual(response.status_code, 401) # print response.content # check response details print "%s = %s" % (response.status_code,'401') Look_For_What = PERMISSION_DENIED print response.content Test_End() return
def setUp_Test_For_Valid_Tester(self): Test_Start() Test_Msg("TestForValidUser-setUp - calling login_to_hive") setup_access = login_to_hive(USERNAME_FOR_TEST, PASSWORD_FOR_TEST,SMSCODE_FOR_TEST) Test_Msg("Login to Hive returned:"+str(setup_access)+" \n for User:"+USERNAME_FOR_TEST) Test_End() return
def test_login_invalid_user(self): Test_Start() result = login_to_hive(USERNAME_NO_ACCOUNT_TEST,PASSWORD_NO_ACCOUNT_TEST,SMSCODE_NO_ACCOUNT_TEST) if result==401: Test_Msg(" Successful result for: "+USERNAME_NO_ACCOUNT_TEST+"/"+PASSWORD_NO_ACCOUNT_TEST+"("+SMSCODE_NO_ACCOUNT_TEST+"):"+ str(result)) else: Test_Msg(" Failed Result - "+str(result)+" using: "+USERNAME_NO_ACCOUNT_TEST+"/"+PASSWORD_NO_ACCOUNT_TEST+"("+SMSCODE_NO_ACCOUNT_TEST+")") Test_End() return
def test_get_record_for_valid_pat_id_with_tester(self): """ GET completed should return a response Tester should have access """ Test_Start() prn_info = False # We should search for this p = get_object_or_404(PatientProfile, patient_id=VALID_PATIENT_ID) if prn_info!=False: print p self.client = Client() self.client.login(username=USERNAME_FOR_TEST,password=PASSWORD_FOR_TEST) attempt_login = login_to_hive(USERNAME_FOR_TEST, PASSWORD_FOR_TEST,SMSCODE_FOR_TEST) print "login result:"+str(attempt_login) print "get /intake/locator/"+VALID_PATIENT_ID response = self.client.get('/intake/locator/'+VALID_PATIENT_ID,follow=True) got_code = self.assertEqual(response.status_code, 200) # print response.content # check response details print "%s = %s" % (response.status_code,'200') print "checking for VALID_PATIENT_ID in /intake/locator/"+VALID_PATIENT_ID Look_For_What = "(" + VALID_PATIENT_ID + ")" print "Checked for "+Look_For_What try: result = self.assertContains(response,Look_For_What) # result = "skipped" print "None is good: Outcome =" + str(result) except: print "No match in Page /intake/locator/"+VALID_PATIENT_ID print response.content Test_End() return