def change_password_info(self) -> None: result = self.find_app_and_username('What is the app whose information you want change?') if not result: return # show password info obtain_password(result, False) # ask user what should be changed # print('\n') while True: new_data = get_changed_info() new_line = list(result) for i, key in enumerate(('username', 'email', 'placeholder', 'app_name', 'url')): if key in new_data: new_line[i+1] = new_data[key] print_info('The following information will be updated in the database:', new_line[1:]) ans = yes_or_no_question('Do you want to proceed?') if ans == 'y': self.pm.update_password_data(result[0], new_data) print('Information has been updated.') return else: ans2 = yes_or_no_question('Do you want to try again?') if ans2 == 'n': print('Updating cancelled.\n') return
def change_password(self) -> None: result = self.find_app_and_username('What is the app you want to change password for?') # if nothing found, return to main menu if not result: return # show the app and username obtain_password(result, False) self.change_password_in_db(result)
def test_obtain_password_w_reveal(self, capsys, monkeypatch, info, choice): def choose(text=None): return str(choice) monkeypatch.setattr('builtins.input', choose) pm_ui_fcns.obtain_password(info, True) printed = f'\nPassword found.\nApp: {info[4]}\nUsername: {info[1]}\nEmail: {info[2]}\nApp url: {info[5]}\n' on_screen = capsys.readouterr()[0] assert printed in on_screen if choice == 1: assert 'Password has been copied to the clipboard.' in on_screen assert pm_ui_fcns.pyperclip.paste() == info[3] elif choice == 2: assert info[3] in on_screen
def find_password_for_app(self) -> None: result = self.find_app_and_username('Write the name of the app you want password for:') if not result: return obtain_password(result, True)
def test_obtain_password_no_reveal(self, capsys, info): pm_ui_fcns.obtain_password(info, False) printed = f'\nPassword found.\nApp: {info[4]}\nUsername: {info[1]}\nEmail: {info[2]}\nApp url: {info[5]}\n' assert capsys.readouterr()[0] == printed