def test_decrypt_content_copy_clipboard(monkeypatch, capsys): gpg = get_GPG( '{"One": {"user":"******","password":"******","url":"url1","other":"other1"}}', 'secrets_tmp28', '12345') aux = ['One', 'N', 'password'] def mock_raw_input_user(*args, **kwargs): a = aux[0] del aux[0] return a monkeypatch.setattr(__builtin__, 'raw_input', mock_raw_input_user) icmd = InteractiveCMD(gpg) icmd.print_decrypt_content() if platform.system() == 'Darwin': clip_out = pyperclip.paste() assert clip_out == 'pass1' else: out, err = capsys.readouterr() assert out == 'Only Darwin platforms\n' remove_files(['secrets_tmp28'])
def test_decrypt_content_fail_id(monkeypatch, capsys): gpg = get_GPG( '{"One": {"user":"******","password":"******","url":"url1","other":"other1"}}', 'secrets_tmp27', '12345') aux = ['Two', 'One', 'Y', 'N'] def mock_raw_input_user(*args, **kwargs): a = aux[0] del aux[0] return a monkeypatch.setattr(__builtin__, 'raw_input', mock_raw_input_user) icmd = InteractiveCMD(gpg) icmd.print_decrypt_content() out, err = capsys.readouterr() assert out == 'user: user1\npassword: pass1\nurl: url1\nother: other1\n' remove_files(['secrets_tmp27'])