def test_member_not_found(self, ctx, mock_member_repository: MagicMock, member_manager: MemberManager): # Given... new_password = '******' mock_member_repository.update_member = MagicMock( side_effect=MemberNotFoundError) # When... with raises(MemberNotFoundError): member_manager.change_password(ctx, TEST_USERNAME, new_password)
def test_password_too_short(self, ctx, mock_member_repository: MagicMock, member_manager: MemberManager): # Given... new_password = '******' # When... with raises(PasswordTooShortError): member_manager.change_password(ctx, TEST_USERNAME, new_password) # Expect... mock_member_repository.update_member.assert_not_called( ) # Do not update with weak password...
def test_happy_path(self, ctx, mock_member_repository: MagicMock, member_manager: MemberManager): # Given... new_password = '******' new_password_hash = ntlm_hash(new_password) # When... member_manager.change_password(ctx, TEST_USERNAME, new_password) # Expect... mock_member_repository.update_member.assert_called_once_with( ctx, TEST_USERNAME, password=new_password_hash)