Best Python code snippet using Kiwi_python
change_password_task.py
Source:change_password_task.py
1from src.core.interfaces.password_tools import PasswordToolsInterface2from src.core.interfaces.logging import LoggingInterface3from src.core.entities.user import User4from ..task_interface import TaskInterface5from src.core.services.employees import Employees6class ChangePasswordTask(TaskInterface[User]):7 def __init__(8 self,9 logging: LoggingInterface,10 password_tools: PasswordToolsInterface,11 employees: Employees) -> None:12 self.logging = logging13 self.password_tools = password_tools14 self.employees = employees15 def run(self, user_change_password):16 if user_change_password['user_kind'] == 'employee':17 employee = self.employees.one_by_username(18 user_change_password['username'])19 if employee is None:20 self.logging.info(21 'unable to find user with username: ' +22 user_change_password[23 'username'])24 return False25 same_password = self.password_tools.validate(26 employee.password,27 user_change_password[28 'old_password'])29 if not same_password:30 self.logging.info(31 'password does not match for user with username: ' +32 user_change_password[33 'username'])34 return False35 if not self.employees.update_password(36 user_change_password['username'],37 self.password_tools.generate_hashed_password(38 user_change_password['new_password'])):39 return False...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!