def test_pass_config_dir_ClickPath(tmpdir): configdir = tmpdir.join('myconfigdir') configdir.mkdir() user_config_name = 'myconfig' user_config = configdir.join('%s.yaml' % user_config_name).ensure() expect = str(configdir.join('myconfig.yaml')) runner = CliRunner() @click.command() @click.argument( 'config', type=cli.ConfigPath(exists=True, config_dir=(str(configdir))), nargs=-1, ) def config_cmd(config): click.echo(config) def check_cmd(config_arg): return runner.invoke(config_cmd, [config_arg]).output with configdir.as_cwd(): assert expect in check_cmd('myconfig') assert expect in check_cmd('myconfig.yaml') assert expect in check_cmd('./myconfig.yaml') assert str(user_config) in check_cmd( str(configdir.join('myconfig.yaml'))) assert 'file not found' in check_cmd('.tmuxp.json')
def test_scan_config_arg(homedir, configdir, projectdir, monkeypatch): runner = CliRunner() @click.command() @click.argument('config', type=cli.ConfigPath(exists=True), nargs=-1) def config_cmd(config): click.echo(config) monkeypatch.setenv('HOME', str(homedir)) projectdir.join('.tmuxp.yaml').ensure() user_config_name = 'myconfig' user_config = configdir.join('%s.yaml' % user_config_name).ensure() project_config = str(projectdir.join('.tmuxp.yaml')) def check_cmd(config_arg): return runner.invoke(config_cmd, [config_arg]).output with projectdir.as_cwd(): expect = project_config assert expect in check_cmd('.') assert expect in check_cmd('./') assert expect in check_cmd('') assert expect in check_cmd('../project') assert expect in check_cmd('../project/') assert expect in check_cmd('.tmuxp.yaml') assert str(user_config) in check_cmd('../../.tmuxp/%s.yaml' % user_config_name) assert user_config.purebasename in check_cmd('myconfig') assert str(user_config) in check_cmd('~/.tmuxp/myconfig.yaml') assert 'file not found' in check_cmd('.tmuxp.json') assert 'file not found' in check_cmd('.tmuxp.ini') assert 'No tmuxp files found' in check_cmd('../') assert 'config not found in config dir' in check_cmd('moo')