1
0
Fork 0
mirror of synced 2024-11-17 06:45:33 -05:00

Rename yadm_y -> yadm_cmd

-Y is no longer used when running commands
This commit is contained in:
Tim Byrne 2020-11-17 14:38:31 -06:00
parent 8efe2c8fad
commit 62b109ad2d
No known key found for this signature in database
GPG key ID: 14DB4FC2465A4B12
19 changed files with 118 additions and 116 deletions

View file

@ -336,7 +336,7 @@ def paths(tmpdir, yadm):
@pytest.fixture()
def yadm_y(paths):
def yadm_cmd(paths):
"""Generate custom command_list function"""
def command_list(*args):
"""Produce params for running yadm with -Y"""

View file

@ -152,15 +152,15 @@ def test_alt_templates(
@pytest.mark.usefixtures('ds1_copy')
@pytest.mark.parametrize('autoalt', [None, 'true', 'false'])
def test_auto_alt(runner, yadm_y, paths, autoalt):
def test_auto_alt(runner, yadm_cmd, paths, autoalt):
"""Test auto alt"""
# set the value of auto-alt
if autoalt:
os.system(' '.join(yadm_y('config', 'yadm.auto-alt', autoalt)))
os.system(' '.join(yadm_cmd('config', 'yadm.auto-alt', autoalt)))
utils.create_alt_files(paths, '##default')
run = runner(yadm_y('status'))
run = runner(yadm_cmd('status'))
assert run.success
assert run.err == ''
linked = utils.parse_alt_output(run.out)
@ -185,7 +185,7 @@ def test_auto_alt(runner, yadm_y, paths, autoalt):
@pytest.mark.usefixtures('ds1_copy')
def test_stale_link_removal(runner, yadm_y, paths):
def test_stale_link_removal(runner, yadm_cmd, paths):
"""Stale links to alternative files are removed
This test ensures that when an already linked alternative becomes invalid
@ -200,7 +200,7 @@ def test_stale_link_removal(runner, yadm_y, paths):
utils.create_alt_files(paths, f'##class.{tst_class}')
# run alt to trigger linking
run = runner(yadm_y('alt'))
run = runner(yadm_cmd('alt'))
assert run.success
assert run.err == ''
linked = utils.parse_alt_output(run.out)
@ -222,7 +222,7 @@ def test_stale_link_removal(runner, yadm_y, paths):
utils.set_local(paths, 'class', 'changedclass')
# run alt to trigger linking
run = runner(yadm_y('alt'))
run = runner(yadm_cmd('alt'))
assert run.success
assert run.err == ''
linked = utils.parse_alt_output(run.out)
@ -235,7 +235,7 @@ def test_stale_link_removal(runner, yadm_y, paths):
@pytest.mark.usefixtures('ds1_repo_copy')
def test_template_overwrite_symlink(runner, yadm_y, paths, tst_sys):
def test_template_overwrite_symlink(runner, yadm_cmd, paths, tst_sys):
"""Remove symlinks before processing a template
If a symlink is in the way of the output of a template, the target of the
@ -252,7 +252,7 @@ def test_template_overwrite_symlink(runner, yadm_y, paths, tst_sys):
template = paths.work.join('test_link##template.default')
template.write('test-data')
run = runner(yadm_y('add', target, template))
run = runner(yadm_cmd('add', target, template))
assert run.success
assert run.err == ''
assert run.out == ''

View file

@ -25,7 +25,7 @@ import pytest
])
@pytest.mark.usefixtures('ds1_copy')
def test_alt_copy(
runner, yadm_y, paths, tst_sys,
runner, yadm_cmd, paths, tst_sys,
setting, expect_link, pre_existing,
cygwin):
"""Test yadm.alt-copy"""
@ -33,7 +33,7 @@ def test_alt_copy(
option = 'yadm.cygwin-copy' if cygwin else 'yadm.alt-copy'
if setting is not None:
os.system(' '.join(yadm_y('config', option, str(setting))))
os.system(' '.join(yadm_cmd('config', option, str(setting))))
expected_content = f'test_alt_copy##os.{tst_sys}'
@ -43,7 +43,7 @@ def test_alt_copy(
elif pre_existing == 'file':
alt_path.write('wrong content')
run = runner(yadm_y('alt'))
run = runner(yadm_cmd('alt'))
assert run.success
assert run.err == ''
assert 'Linking' in run.out

View file

@ -9,7 +9,7 @@ PRIVATE_DIRS = ['.gnupg', '.ssh']
@pytest.mark.parametrize('home', [True, False], ids=['home', 'not-home'])
def test_pdirs_missing(runner, yadm_y, paths, home):
def test_pdirs_missing(runner, yadm_cmd, paths, home):
"""Private dirs (private dirs missing)
When a git command is run
@ -29,7 +29,7 @@ def test_pdirs_missing(runner, yadm_y, paths, home):
env['HOME'] = paths.work
# run status
run = runner(command=yadm_y('status'), env=env)
run = runner(command=yadm_cmd('status'), env=env)
assert run.success
assert run.err == ''
assert 'On branch master' in run.out
@ -53,7 +53,7 @@ def test_pdirs_missing(runner, yadm_y, paths, home):
run.out, re.DOTALL), 'directories created before command is run'
def test_pdirs_missing_apd_false(runner, yadm_y, paths):
def test_pdirs_missing_apd_false(runner, yadm_cmd, paths):
"""Private dirs (private dirs missing / yadm.auto-private-dirs=false)
When a git command is run
@ -70,11 +70,11 @@ def test_pdirs_missing_apd_false(runner, yadm_y, paths):
assert not path.exists()
# set configuration
os.system(' '.join(yadm_y(
os.system(' '.join(yadm_cmd(
'config', '--bool', 'yadm.auto-private-dirs', 'false')))
# run status
run = runner(command=yadm_y('status'))
run = runner(command=yadm_cmd('status'))
assert run.success
assert run.err == ''
assert 'On branch master' in run.out
@ -84,7 +84,7 @@ def test_pdirs_missing_apd_false(runner, yadm_y, paths):
assert not paths.work.join(pdir).exists()
def test_pdirs_exist_apd_false(runner, yadm_y, paths):
def test_pdirs_exist_apd_false(runner, yadm_cmd, paths):
"""Private dirs (private dirs exist / yadm.auto-perms=false)
When a git command is run
@ -102,11 +102,11 @@ def test_pdirs_exist_apd_false(runner, yadm_y, paths):
assert oct(path.stat().mode).endswith('77'), 'Directory is secure.'
# set configuration
os.system(' '.join(yadm_y(
os.system(' '.join(yadm_cmd(
'config', '--bool', 'yadm.auto-perms', 'false')))
# run status
run = runner(command=yadm_y('status'))
run = runner(command=yadm_cmd('status'))
assert run.success
assert run.err == ''
assert 'On branch master' in run.out

View file

@ -14,7 +14,7 @@ import pytest
'executable',
])
def test_bootstrap(
runner, yadm_y, paths, exists, executable, code, expect):
runner, yadm_cmd, paths, exists, executable, code, expect):
"""Test bootstrap command"""
if exists:
paths.bootstrap.write('')
@ -25,7 +25,7 @@ def test_bootstrap(
f'exit {code}\n'
)
paths.bootstrap.chmod(0o775)
run = runner(command=yadm_y('bootstrap'))
run = runner(command=yadm_cmd('bootstrap'))
assert run.code == code
assert run.err == ''
assert expect in run.out

View file

@ -1,9 +1,9 @@
"""Test clean"""
def test_clean_command(runner, yadm_y):
def test_clean_command(runner, yadm_cmd):
"""Run with clean command"""
run = runner(command=yadm_y('clean'))
run = runner(command=yadm_cmd('clean'))
# do nothing, this is a dangerous Git command when managing dot files
# report the command as disabled and exit as a failure
assert run.failure

View file

@ -24,7 +24,7 @@ BOOTSTRAP_MSG = 'Bootstrap successful'
'conflicts',
])
def test_clone(
runner, paths, yadm_y, repo_config, ds1,
runner, paths, yadm_cmd, repo_config, ds1,
good_remote, repo_exists, force, conflicts):
"""Test basic clone operation"""
@ -53,7 +53,7 @@ def test_clone(
if force:
args += ['-f']
args += [remote_url]
run = runner(command=yadm_y(*args))
run = runner(command=yadm_cmd(*args))
if not good_remote:
# clone should fail
@ -88,20 +88,21 @@ def test_clone(
if conflicts:
# test to see if the work tree is actually "clean"
run = runner(
command=yadm_y('status', '-uno', '--porcelain'),
command=yadm_cmd('status', '-uno', '--porcelain'),
cwd=paths.work)
assert run.success
assert run.err == ''
assert run.out == '', 'worktree has unexpected changes'
# test to see if the conflicts are stashed
run = runner(command=yadm_y('stash', 'list'), cwd=paths.work)
run = runner(command=yadm_cmd('stash', 'list'), cwd=paths.work)
assert run.success
assert run.err == ''
assert 'Conflicts preserved' in run.out, 'conflicts not stashed'
# verify content of the stashed conflicts
run = runner(command=yadm_y('stash', 'show', '-p'), cwd=paths.work)
run = runner(
command=yadm_cmd('stash', 'show', '-p'), cwd=paths.work)
assert run.success
assert run.err == ''
assert '\n+conflict' in run.out, 'conflicts not stashed'
@ -130,7 +131,7 @@ def test_clone(
'existing, answer y',
])
def test_clone_bootstrap(
runner, paths, yadm_y, repo_config, bs_exists, bs_param, answer):
runner, paths, yadm_cmd, repo_config, bs_exists, bs_param, answer):
"""Test bootstrap clone features"""
# establish a bootstrap
@ -144,7 +145,7 @@ def test_clone_bootstrap(
expect = []
if answer:
expect.append(('Would you like to execute it now', answer))
run = runner(command=yadm_y(*args), expect=expect)
run = runner(command=yadm_cmd(*args), expect=expect)
if answer:
assert 'Would you like to execute it now' in run.out
@ -197,7 +198,7 @@ def create_bootstrap(paths, exists):
'missing gnupg, tracked',
])
def test_clone_perms(
runner, yadm_y, paths, repo_config,
runner, yadm_cmd, paths, repo_config,
private_type, in_repo, in_work):
"""Test clone permission-related functions"""
@ -224,7 +225,7 @@ def test_clone_perms(
env = {'HOME': paths.work}
run = runner(
yadm_y('clone', '-d', '-w', paths.work, f'file://{paths.remote}'),
yadm_cmd('clone', '-d', '-w', paths.work, f'file://{paths.remote}'),
env=env
)
@ -260,7 +261,7 @@ def test_clone_perms(
@pytest.mark.usefixtures('remote')
@pytest.mark.parametrize('branch', ['master', 'valid', 'invalid'])
def test_alternate_branch(runner, paths, yadm_y, repo_config, branch):
def test_alternate_branch(runner, paths, yadm_cmd, repo_config, branch):
"""Test cloning a branch other than master"""
# add a "valid" branch to the remote
@ -280,7 +281,7 @@ def test_alternate_branch(runner, paths, yadm_y, repo_config, branch):
if branch != 'master':
args += ['-b', branch]
args += [remote_url]
run = runner(command=yadm_y(*args))
run = runner(command=yadm_cmd(*args))
if branch == 'invalid':
assert run.failure
@ -296,7 +297,7 @@ def test_alternate_branch(runner, paths, yadm_y, repo_config, branch):
assert run.success
assert run.err == ''
assert f'origin\t{remote_url}' in run.out
run = runner(command=yadm_y('show'))
run = runner(command=yadm_cmd('show'))
if branch == 'valid':
assert 'This branch is valid' in run.out
else:

View file

@ -10,7 +10,7 @@ TEST_VALUE = 'testvalue'
TEST_FILE = f'[{TEST_SECTION}]\n\t{TEST_ATTRIBUTE} = {TEST_VALUE}'
def test_config_no_params(runner, yadm_y, supported_configs):
def test_config_no_params(runner, yadm_cmd, supported_configs):
"""No parameters
Display instructions
@ -18,7 +18,7 @@ def test_config_no_params(runner, yadm_y, supported_configs):
Exit with 0
"""
run = runner(yadm_y('config'))
run = runner(yadm_cmd('config'))
assert run.success
assert run.err == ''
@ -27,21 +27,21 @@ def test_config_no_params(runner, yadm_y, supported_configs):
assert config in run.out
def test_config_read_missing(runner, yadm_y):
def test_config_read_missing(runner, yadm_cmd):
"""Read missing attribute
Display an empty value
Exit with 0
"""
run = runner(yadm_y('config', TEST_KEY))
run = runner(yadm_cmd('config', TEST_KEY))
assert run.success
assert run.err == ''
assert run.out == ''
def test_config_write(runner, yadm_y, paths):
def test_config_write(runner, yadm_cmd, paths):
"""Write attribute
Display no output
@ -49,7 +49,7 @@ def test_config_write(runner, yadm_y, paths):
Exit with 0
"""
run = runner(yadm_y('config', TEST_KEY, TEST_VALUE))
run = runner(yadm_cmd('config', TEST_KEY, TEST_VALUE))
assert run.success
assert run.err == ''
@ -57,7 +57,7 @@ def test_config_write(runner, yadm_y, paths):
assert paths.config.read().strip() == TEST_FILE
def test_config_read(runner, yadm_y, paths):
def test_config_read(runner, yadm_cmd, paths):
"""Read attribute
Display value
@ -65,14 +65,14 @@ def test_config_read(runner, yadm_y, paths):
"""
paths.config.write(TEST_FILE)
run = runner(yadm_y('config', TEST_KEY))
run = runner(yadm_cmd('config', TEST_KEY))
assert run.success
assert run.err == ''
assert run.out.strip() == TEST_VALUE
def test_config_update(runner, yadm_y, paths):
def test_config_update(runner, yadm_cmd, paths):
"""Update attribute
Display no output
@ -82,7 +82,7 @@ def test_config_update(runner, yadm_y, paths):
paths.config.write(TEST_FILE)
run = runner(yadm_y('config', TEST_KEY, TEST_VALUE + 'extra'))
run = runner(yadm_cmd('config', TEST_KEY, TEST_VALUE + 'extra'))
assert run.success
assert run.err == ''
@ -92,7 +92,7 @@ def test_config_update(runner, yadm_y, paths):
@pytest.mark.usefixtures('ds1_repo_copy')
def test_config_local_read(runner, yadm_y, paths, supported_local_configs):
def test_config_local_read(runner, yadm_cmd, paths, supported_local_configs):
"""Read local attribute
Display value from the repo config
@ -107,14 +107,14 @@ def test_config_local_read(runner, yadm_y, paths, supported_local_configs):
# run yadm config
for config in supported_local_configs:
run = runner(yadm_y('config', config))
run = runner(yadm_cmd('config', config))
assert run.success
assert run.err == ''
assert run.out.strip() == f'value_of_{config}'
@pytest.mark.usefixtures('ds1_repo_copy')
def test_config_local_write(runner, yadm_y, paths, supported_local_configs):
def test_config_local_write(runner, yadm_cmd, paths, supported_local_configs):
"""Write local attribute
Display no output
@ -124,7 +124,7 @@ def test_config_local_write(runner, yadm_y, paths, supported_local_configs):
# run yadm config
for config in supported_local_configs:
run = runner(yadm_y('config', config, f'value_of_{config}'))
run = runner(yadm_cmd('config', config, f'value_of_{config}'))
assert run.success
assert run.err == ''
assert run.out == ''
@ -139,7 +139,7 @@ def test_config_local_write(runner, yadm_y, paths, supported_local_configs):
assert run.out.strip() == f'value_of_{config}'
def test_config_without_parent_directory(runner, yadm_y, paths):
def test_config_without_parent_directory(runner, yadm_cmd, paths):
"""Write and read attribute to/from config file with non-existent parent dir
Update configuration file
@ -150,13 +150,13 @@ def test_config_without_parent_directory(runner, yadm_y, paths):
config_file = paths.root + '/folder/does/not/exist/config'
run = runner(
yadm_y('--yadm-config', config_file, 'config', TEST_KEY, TEST_VALUE))
yadm_cmd('--yadm-config', config_file, 'config', TEST_KEY, TEST_VALUE))
assert run.success
assert run.err == ''
assert run.out == ''
run = runner(yadm_y('--yadm-config', config_file, 'config', TEST_KEY))
run = runner(yadm_cmd('--yadm-config', config_file, 'config', TEST_KEY))
assert run.success
assert run.err == ''

View file

@ -61,7 +61,7 @@ def asymmetric_key(runner, gnupg):
@pytest.fixture
def encrypt_targets(yadm_y, paths):
def encrypt_targets(yadm_cmd, paths):
"""Fixture for setting up data to encrypt
This fixture:
@ -78,7 +78,7 @@ def encrypt_targets(yadm_y, paths):
"""
# init empty yadm repo
os.system(' '.join(yadm_y('init', '-w', str(paths.work), '-f')))
os.system(' '.join(yadm_cmd('init', '-w', str(paths.work), '-f')))
expected = []
@ -186,7 +186,7 @@ def decrypt_targets(tmpdir_factory, runner, gnupg):
'overwrite', [False, True],
ids=['clean', 'overwrite'])
def test_symmetric_encrypt(
runner, yadm_y, paths, encrypt_targets,
runner, yadm_cmd, paths, encrypt_targets,
gnupg, bad_phrase, overwrite, missing_encrypt):
"""Test symmetric encryption"""
@ -203,7 +203,7 @@ def test_symmetric_encrypt(
env = os.environ.copy()
env['GNUPGHOME'] = gnupg.home
run = runner(yadm_y('encrypt'), env=env)
run = runner(yadm_cmd('encrypt'), env=env)
if missing_encrypt or bad_phrase:
assert run.failure
@ -230,12 +230,12 @@ def test_symmetric_encrypt(
'dolist', [False, True],
ids=['decrypt', 'list'])
def test_symmetric_decrypt(
runner, yadm_y, paths, decrypt_targets, gnupg,
runner, yadm_cmd, paths, decrypt_targets, gnupg,
dolist, archive_exists, bad_phrase):
"""Test decryption"""
# init empty yadm repo
os.system(' '.join(yadm_y('init', '-w', str(paths.work), '-f')))
os.system(' '.join(yadm_cmd('init', '-w', str(paths.work), '-f')))
if bad_phrase:
gnupg.pw('')
@ -256,7 +256,7 @@ def test_symmetric_decrypt(
if dolist:
args.append('-l')
run = runner(yadm_y('decrypt') + args, env=env)
run = runner(yadm_cmd('decrypt') + args, env=env)
if archive_exists and not bad_phrase:
assert run.success
@ -284,16 +284,16 @@ def test_symmetric_decrypt(
'overwrite', [False, True],
ids=['clean', 'overwrite'])
def test_asymmetric_encrypt(
runner, yadm_y, paths, encrypt_targets, gnupg,
runner, yadm_cmd, paths, encrypt_targets, gnupg,
overwrite, key_exists, ask):
"""Test asymmetric encryption"""
# specify encryption recipient
if ask:
os.system(' '.join(yadm_y('config', 'yadm.gpg-recipient', 'ASK')))
os.system(' '.join(yadm_cmd('config', 'yadm.gpg-recipient', 'ASK')))
expect = [('Enter the user ID', KEY_NAME), ('Enter the user ID', '')]
else:
os.system(' '.join(yadm_y('config', 'yadm.gpg-recipient', KEY_NAME)))
os.system(' '.join(yadm_cmd('config', 'yadm.gpg-recipient', KEY_NAME)))
expect = []
if overwrite:
@ -305,7 +305,7 @@ def test_asymmetric_encrypt(
env = os.environ.copy()
env['GNUPGHOME'] = gnupg.home
run = runner(yadm_y('encrypt'), env=env, expect=expect)
run = runner(yadm_cmd('encrypt'), env=env, expect=expect)
if key_exists:
assert run.success
@ -321,17 +321,17 @@ def test_asymmetric_encrypt(
@pytest.mark.usefixtures('asymmetric_key')
@pytest.mark.usefixtures('encrypt_targets')
def test_multi_key(runner, yadm_y, gnupg):
def test_multi_key(runner, yadm_cmd, gnupg):
"""Test multiple recipients"""
# specify two encryption recipient
os.system(' '.join(yadm_y(
os.system(' '.join(yadm_cmd(
'config', 'yadm.gpg-recipient', f'"{KEY_NAME} second-key"')))
env = os.environ.copy()
env['GNUPGHOME'] = gnupg.home
run = runner(yadm_y('encrypt'), env=env)
run = runner(yadm_cmd('encrypt'), env=env)
assert run.failure
assert 'second-key: skipped: No public key' in run.err
@ -345,12 +345,12 @@ def test_multi_key(runner, yadm_y, gnupg):
'dolist', [False, True],
ids=['decrypt', 'list'])
def test_asymmetric_decrypt(
runner, yadm_y, paths, decrypt_targets, gnupg,
runner, yadm_cmd, paths, decrypt_targets, gnupg,
dolist, key_exists):
"""Test decryption"""
# init empty yadm repo
os.system(' '.join(yadm_y('init', '-w', str(paths.work), '-f')))
os.system(' '.join(yadm_cmd('init', '-w', str(paths.work), '-f')))
decrypt_targets['asymmetric'].copy(paths.archive)
@ -366,7 +366,7 @@ def test_asymmetric_decrypt(
args.append('-l')
env = os.environ.copy()
env['GNUPGHOME'] = gnupg.home
run = runner(yadm_y('decrypt') + args, env=env)
run = runner(yadm_cmd('decrypt') + args, env=env)
if key_exists:
assert run.success
@ -388,7 +388,7 @@ def test_asymmetric_decrypt(
[False, 'y', 'n'],
ids=['tracked', 'untracked_answer_y', 'untracked_answer_n'])
def test_offer_to_add(
runner, yadm_y, paths, encrypt_targets, gnupg, untracked):
runner, yadm_cmd, paths, encrypt_targets, gnupg, untracked):
"""Test offer to add encrypted archive
All the other encryption tests use an archive outside of the work tree.
@ -408,10 +408,10 @@ def test_offer_to_add(
expect.append(('add it now', untracked))
else:
worktree_archive.write('exists')
os.system(' '.join(yadm_y('add', str(worktree_archive))))
os.system(' '.join(yadm_cmd('add', str(worktree_archive))))
run = runner(
yadm_y('encrypt', '--yadm-archive', str(worktree_archive)),
yadm_cmd('encrypt', '--yadm-archive', str(worktree_archive)),
env=env,
expect=expect
)
@ -422,7 +422,7 @@ def test_offer_to_add(
runner, gnupg, worktree_archive, encrypt_targets)
run = runner(
yadm_y('status', '--porcelain', '-uall', str(worktree_archive)))
yadm_cmd('status', '--porcelain', '-uall', str(worktree_archive)))
assert run.success
assert run.err == ''
@ -438,7 +438,7 @@ def test_offer_to_add(
@pytest.mark.usefixtures('ds1_copy')
def test_encrypt_added_to_exclude(runner, yadm_y, paths, gnupg):
def test_encrypt_added_to_exclude(runner, yadm_cmd, paths, gnupg):
"""Confirm that .config/yadm/encrypt is added to exclude"""
gnupg.pw(PASSPHRASE)
@ -450,7 +450,7 @@ def test_encrypt_added_to_exclude(runner, yadm_y, paths, gnupg):
paths.work.join('test-encrypt-data').write('')
exclude_file.write('original-data', ensure=True)
run = runner(yadm_y('encrypt'), env=env)
run = runner(yadm_cmd('encrypt'), env=env)
assert 'test-encrypt-data' in paths.repo.join('info/exclude').read()
assert 'original-data' in paths.repo.join('info/exclude').read()

View file

@ -17,7 +17,7 @@ import pytest
'shell-noexec',
])
@pytest.mark.usefixtures('ds1_copy')
def test_enter(runner, yadm_y, paths, shell, success):
def test_enter(runner, yadm_cmd, paths, shell, success):
"""Enter tests"""
env = os.environ.copy()
if shell == 'delete':
@ -33,7 +33,7 @@ def test_enter(runner, yadm_y, paths, shell, success):
else:
env['SHELL'] = shell
run = runner(command=yadm_y('enter'), env=env)
run = runner(command=yadm_cmd('enter'), env=env)
assert run.success == success
assert run.err == ''
prompt = f'yadm shell ({paths.repo})'
@ -64,7 +64,7 @@ def test_enter(runner, yadm_y, paths, shell, success):
[False, 'cmd', 'cmd-bad-exit'],
ids=['no-cmd', 'cmd', 'cmd-bad-exit'])
@pytest.mark.usefixtures('ds1_copy')
def test_enter_shell_ops(runner, yadm_y, paths, shell, opts, path, cmd):
def test_enter_shell_ops(runner, yadm_cmd, paths, shell, opts, path, cmd):
"""Enter tests for specific shell options"""
change_exit = '\nfalse' if cmd == 'cmd-bad-exit' else ''
@ -85,7 +85,7 @@ def test_enter_shell_ops(runner, yadm_y, paths, shell, opts, path, cmd):
env = os.environ.copy()
env['SHELL'] = custom_shell
run = runner(command=yadm_y(*enter_cmd), env=env)
run = runner(command=yadm_cmd(*enter_cmd), env=env)
if cmd == 'cmd-bad-exit':
assert run.failure
else:

View file

@ -5,7 +5,7 @@ import pytest
@pytest.mark.usefixtures('ds1_copy')
def test_git(runner, yadm_y, paths):
def test_git(runner, yadm_cmd, paths):
"""Test series of passthrough git commands
Passthru unknown commands to Git
@ -17,14 +17,14 @@ def test_git(runner, yadm_y, paths):
"""
# passthru unknown commands to Git
run = runner(command=yadm_y('bogus'))
run = runner(command=yadm_cmd('bogus'))
assert run.failure
assert "git: 'bogus' is not a git command." in run.err
assert "See 'git --help'" in run.err
assert run.out == ''
# git command 'add' - badfile
run = runner(command=yadm_y('add', '-v', 'does_not_exist'))
run = runner(command=yadm_cmd('add', '-v', 'does_not_exist'))
assert run.code == 128
assert "pathspec 'does_not_exist' did not match any files" in run.err
assert run.out == ''
@ -32,19 +32,19 @@ def test_git(runner, yadm_y, paths):
# git command 'add'
newfile = paths.work.join('test_git')
newfile.write('test_git')
run = runner(command=yadm_y('add', '-v', str(newfile)))
run = runner(command=yadm_cmd('add', '-v', str(newfile)))
assert run.success
assert run.err == ''
assert "add 'test_git'" in run.out
# git command 'status'
run = runner(command=yadm_y('status'))
run = runner(command=yadm_cmd('status'))
assert run.success
assert run.err == ''
assert re.search(r'new file:\s+test_git', run.out)
# git command 'commit'
run = runner(command=yadm_y('commit', '-m', 'Add test_git'))
run = runner(command=yadm_cmd('commit', '-m', 'Add test_git'))
assert run.success
assert run.err == ''
assert '1 file changed' in run.out
@ -52,7 +52,7 @@ def test_git(runner, yadm_y, paths):
assert re.search(r'create mode .+ test_git', run.out)
# git command 'log'
run = runner(command=yadm_y('log', '--oneline'))
run = runner(command=yadm_cmd('log', '--oneline'))
assert run.success
assert run.err == ''
assert 'Add test_git' in run.out

View file

@ -1,17 +1,17 @@
"""Test help"""
def test_missing_command(runner, yadm_y):
def test_missing_command(runner, yadm_cmd):
"""Run without any command"""
run = runner(command=yadm_y())
run = runner(command=yadm_cmd())
assert run.failure
assert run.err == ''
assert run.out.startswith('Usage: yadm')
def test_help_command(runner, yadm_y):
def test_help_command(runner, yadm_cmd):
"""Run with help command"""
run = runner(command=yadm_y('help'))
run = runner(command=yadm_cmd('help'))
assert run.failure
assert run.err == ''
assert run.out.startswith('Usage: yadm')

View file

@ -22,7 +22,7 @@ import pytest
'pre-post-fail',
])
def test_hooks(
runner, yadm_y, paths,
runner, yadm_cmd, paths,
pre, pre_code, post, post_code):
"""Test pre/post hook"""
@ -33,7 +33,7 @@ def test_hooks(
create_hook(paths, 'post_version', post_code)
# run yadm
run = runner(yadm_y('version'))
run = runner(yadm_cmd('version'))
# when a pre hook fails, yadm should exit with the hook's code
assert run.code == pre_code
assert run.err == ''
@ -53,7 +53,7 @@ def test_hooks(
# repo fixture is needed to test the population of YADM_HOOK_WORK
@pytest.mark.usefixtures('ds1_repo_copy')
def test_hook_env(runner, yadm_y, paths):
def test_hook_env(runner, yadm_cmd, paths):
"""Test hook environment"""
# test will be done with a non existent "git" passthru command
@ -65,7 +65,7 @@ def test_hook_env(runner, yadm_y, paths):
hook.write('#!/bin/bash\nenv\ndeclare\n')
hook.chmod(0o755)
run = runner(yadm_y(cmd, 'extra_args'))
run = runner(yadm_cmd(cmd, 'extra_args'))
# expect passthru to fail
assert run.failure
@ -103,7 +103,7 @@ def test_hook_env(runner, yadm_y, paths):
assert 'YADM_ENCRYPT_INCLUDE_FILES=a\nb\nc\n' in run.out
def test_escaped(runner, yadm_y, paths):
def test_escaped(runner, yadm_cmd, paths):
"""Test escaped values in YADM_HOOK_FULL_COMMAND"""
# test will be done with a non existent "git" passthru command
@ -115,7 +115,7 @@ def test_escaped(runner, yadm_y, paths):
hook.write('#!/bin/bash\nenv\n')
hook.chmod(0o755)
run = runner(yadm_y(cmd, 'a b', 'c\td', 'e\\f'))
run = runner(yadm_cmd(cmd, 'a b', 'c\td', 'e\\f'))
# expect passthru to fail
assert run.failure

View file

@ -19,7 +19,7 @@ import pytest
])
@pytest.mark.usefixtures('ds1_work_copy')
def test_init(
runner, yadm_y, paths, repo_config, alt_work, repo_present, force):
runner, yadm_cmd, paths, repo_config, alt_work, repo_present, force):
"""Test init
Repos should have attribs:
@ -51,7 +51,7 @@ def test_init(
args.append('-f')
# run init
run = runner(yadm_y(*args), env={'HOME': home})
run = runner(yadm_cmd(*args), env={'HOME': home})
assert run.err == ''
if repo_present and not force:

View file

@ -13,13 +13,13 @@ import pytest
'switches',
])
def test_introspect_category(
runner, yadm_y, paths, name,
runner, yadm_cmd, paths, name,
supported_commands, supported_configs, supported_switches):
"""Validate introspection category"""
if name:
run = runner(command=yadm_y('introspect', name))
run = runner(command=yadm_cmd('introspect', name))
else:
run = runner(command=yadm_y('introspect'))
run = runner(command=yadm_cmd('introspect'))
assert run.success
assert run.err == ''

View file

@ -11,7 +11,7 @@ import pytest
'subdir',
])
@pytest.mark.usefixtures('ds1_copy')
def test_list(runner, yadm_y, paths, ds1, location):
def test_list(runner, yadm_cmd, paths, ds1, location):
"""List tests"""
if location == 'work':
run_dir = paths.work
@ -23,7 +23,7 @@ def test_list(runner, yadm_y, paths, ds1, location):
with run_dir.as_cwd():
# test with '-a'
# should get all tracked files, relative to the work path
run = runner(command=yadm_y('list', '-a'))
run = runner(command=yadm_cmd('list', '-a'))
assert run.success
assert run.err == ''
returned_files = set(run.out.splitlines())
@ -33,7 +33,7 @@ def test_list(runner, yadm_y, paths, ds1, location):
# should get all tracked files, relative to the work path unless in a
# subdir, then those should be a limited set of files, relative to the
# subdir
run = runner(command=yadm_y('list'))
run = runner(command=yadm_cmd('list'))
assert run.success
assert run.err == ''
returned_files = set(run.out.splitlines())

View file

@ -6,12 +6,13 @@ import pytest
@pytest.mark.parametrize('autoperms', ['notest', 'unset', 'true', 'false'])
@pytest.mark.usefixtures('ds1_copy')
def test_perms(runner, yadm_y, paths, ds1, autoperms):
def test_perms(runner, yadm_cmd, paths, ds1, autoperms):
"""Test perms"""
# set the value of auto-perms
if autoperms != 'notest':
if autoperms != 'unset':
os.system(' '.join(yadm_y('config', 'yadm.auto-perms', autoperms)))
os.system(' '.join(
yadm_cmd('config', 'yadm.auto-perms', autoperms)))
# privatepaths will hold all paths that should become secured
privatepaths = [paths.work.join('.ssh'), paths.work.join('.gnupg')]
@ -38,7 +39,7 @@ def test_perms(runner, yadm_y, paths, ds1, autoperms):
cmd = 'perms'
if autoperms != 'notest':
cmd = 'status'
run = runner(yadm_y(cmd), env={'HOME': paths.work})
run = runner(yadm_cmd(cmd), env={'HOME': paths.work})
assert run.success
assert run.err == ''
if cmd == 'perms':
@ -62,15 +63,15 @@ def test_perms(runner, yadm_y, paths, ds1, autoperms):
@pytest.mark.parametrize('sshperms', [None, 'true', 'false'])
@pytest.mark.parametrize('gpgperms', [None, 'true', 'false'])
@pytest.mark.usefixtures('ds1_copy')
def test_perms_control(runner, yadm_y, paths, ds1, sshperms, gpgperms):
def test_perms_control(runner, yadm_cmd, paths, ds1, sshperms, gpgperms):
"""Test fine control of perms"""
# set the value of ssh-perms
if sshperms:
os.system(' '.join(yadm_y('config', 'yadm.ssh-perms', sshperms)))
os.system(' '.join(yadm_cmd('config', 'yadm.ssh-perms', sshperms)))
# set the value of gpg-perms
if gpgperms:
os.system(' '.join(yadm_y('config', 'yadm.gpg-perms', gpgperms)))
os.system(' '.join(yadm_cmd('config', 'yadm.gpg-perms', gpgperms)))
# privatepaths will hold all paths that should become secured
privatepaths = [paths.work.join('.ssh'), paths.work.join('.gnupg')]
@ -81,7 +82,7 @@ def test_perms_control(runner, yadm_y, paths, ds1, sshperms, gpgperms):
assert not oct(private.stat().mode).endswith('00'), (
'Path started secured')
run = runner(yadm_y('perms'), env={'HOME': paths.work})
run = runner(yadm_cmd('perms'), env={'HOME': paths.work})
assert run.success
assert run.err == ''
assert run.out == ''

View file

@ -16,12 +16,12 @@ import pytest
])
@pytest.mark.parametrize('program', ['git', 'gpg'])
def test_x_program(
runner, yadm_y, paths, program, executable, success, value, match):
runner, yadm_cmd, paths, program, executable, success, value, match):
"""Set yadm.X-program, and test result of require_X"""
# set configuration
if executable:
os.system(' '.join(yadm_y(
os.system(' '.join(yadm_cmd(
'config', f'yadm.{program}-program', executable)))
# test require_[git,gpg]

View file

@ -27,9 +27,9 @@ def test_semantic_version(expected_version):
def test_reported_version(
runner, yadm_y, expected_version):
runner, yadm_cmd, expected_version):
"""Report correct version"""
run = runner(command=yadm_y('version'))
run = runner(command=yadm_cmd('version'))
assert run.success
assert run.err == ''
assert run.out == f'yadm {expected_version}\n'