def test_encrypt_all(delete_file, encrypt, find, expanduser, Inventory, GPGOps): Inventory().__enter__().read_parameters.return_value = saved_params expanduser.side_effect = [ saved_params['plaindir'], saved_params['securedir'], saved_params['gpg_homedir'], saved_params['gpg_binary'] ] find.return_value = { 'test_path_1': { 'modified_time': 1234, 'is_new': False }, 'test_path_2': { 'modified_time': 1337, 'is_new': False }, 'test_path_3': { 'modified_time': 1414, 'is_new': True } } de = DirEncryption(test_args) de.encrypt_all() eq_(encrypt.call_count, 3) eq_(encrypt.call_args_list[0][0][0], 'test_path_1') eq_(encrypt.call_args_list[1][0][0], 'test_path_2') eq_(encrypt.call_args_list[2][0][0], 'test_path_3') eq_(Inventory().__enter__().update_last_timestamp.call_count, 1) eq_(delete_file.call_count, 2)
def test_encrypt_all(maintenance, register_links, register_dirs, encrypt_files): de = DirEncryption(test_args) de.encrypt_all() eq_(maintenance.call_count, 1) eq_(register_links.call_count, 1) eq_(register_dirs.call_count, 1) eq_(encrypt_files.call_count, 1)
def test_encrypt_all__no_files(encrypt, find, expanduser, Inventory, GPGOps): expanduser.side_effect = [ saved_params['plaindir'], saved_params['securedir'], saved_params['gpg_homedir'], saved_params['gpg_binary'] ] de = DirEncryption(test_args) de.encrypt_all() eq_(encrypt.call_count, 0) eq_(Inventory().__enter__().update_last_timestamp.call_count, 1)
help='Print verbose messages during execution') parser.add_argument('-p', '--plaindir', help='Unencrypted directory') parser.add_argument('-s', '--securedir', help='Encrypted directory') parser.add_argument('-i', '--public-id', help='GPG public id') parser.add_argument('-P', '--passphrase', help='Passphrase to decrypt files.') parser.add_argument('-H', '--gpg-homedir', help='GPG home directory') parser.add_argument('-k', '--gpg-keyring', help='GPG keyring file') parser.add_argument('-b', '--gpg-binary', help='GPG binary file') args = parser.parse_args() if args.configure: header() c = RunConfig(database=database) elif args.encrypt: e = DirEncryption(args, database=database) e.encrypt_all() elif args.decrypt: if args.passphrase: passphrase = args.passphrase else: passphrase = getpass.getpass('Passphrase: ') e = DirEncryption(args, database=database) e.decrypt_all(passphrase) else: header() print('Please specify encrypt (-e) or decrypt (-d) operation,') print('or --configure to set up configuration.')