Source code for django_webapps_fullstack.test.test_account_password_renew
"""test program for the django template "password_renew"based on the "unittest" and "selenium" functionality"""importunittestfromselenium.webdriver.common.byimportByfromselenium.webdriver.support.waitimportWebDriverWaitfromselenium.webdriver.supportimportexpected_conditionsasEC# Import base test case for automatic cleanupfromdjango_webapps_fullstack.test.base_test_caseimportReadOnlyDjangoTestCase
[docs]classtest_account_password_renew(ReadOnlyDjangoTestCase):""" Class for the test cases of the django template "password_renew" """
[docs]deftest_cases(self):""" test cases for the template "password_renew" """# Get test parameters from configurationcustom_login=self.config_test.get('get_settings_customer','login')custom_password=self.config_test.get('get_settings_customer','password')custom_title_dashboard=self.config_test.get('get_settings_title','title_dashboard')custom_title_login=self.config_test.get('get_settings_title','title_login')custom_url=self.config_global.get('settings_django_server','url')# find the user for whom the password should be updatedres_users_id=self.models.execute_kw(self.db,self.uid,self.password,'res.users','search',[[['login','=',custom_login],['x_activate_complete','=',False],]])# if a user exist:# update of 'x_activate_complete' so that the password could be uptaded forxinres_users_id:id=xresult=self.models.execute_kw(self.db,self.uid,self.password,'res.users','write',[[id],{'x_activate_complete':True}])# login of the user to create the request session# url of template "login" = '/account/login'self.driver.get(custom_url+'/account/login')# assertion to confirm that the title has the keyword in itassertcustom_title_logininself.driver.title# search and enter email and submit button login=self.driver.find_element(By.ID,'id_login')password=self.driver.find_element(By.ID,'id_password')button=self.driver.find_element(By.CLASS_NAME,'btn-primary')login.send_keys(custom_login)password.send_keys(custom_password)button.click()# wait for the change to the expected title of the new template "dashboard"wait=WebDriverWait(self.driver,80)wait.until(EC.title_contains(custom_title_dashboard))# assertion to test that template "dashboard" is called after submitassertcustom_title_dashboardinself.driver.title# user has been logged into, "password_renew" procedure could be started# url of template "password_renew" = '/account/password_renew'self.driver.get(custom_url+'/account/password_renew')# assertion to confirm that the title has the keyword in itassert'Password Renew'inself.driver.title# search and enter email and submit button password=self.driver.find_element(By.ID,'id_password')password_confirm=self.driver.find_element(By.ID,'id_password_confirm')button=self.driver.find_element(By.CLASS_NAME,'btn-primary')password.send_keys(custom_password)password_confirm.send_keys(custom_password)button.click()wait=WebDriverWait(self.driver,10)wait.until(EC.title_contains("Password Renew Done"))# assertion to test that template "password_recovery_done" is called after submitself.assertIn("Password Renew Done",self.driver.title)