def test_find_config_include_home_configs( tmpdir, config_dir, sample_yaml_config, sample_json_config ): with EnvironmentVarGuard() as env: env.set("HOME", str(tmpdir)) configs = config.find_config_files( path=[str(config_dir)], match='*', include_home=True ) assert str(sample_yaml_config) in configs assert str(sample_json_config) in configs config_file3 = tmpdir.join('.vcspull.json') config_file3.write('') results = config.find_config_files( path=[str(config_dir)], match='*', include_home=True ) expectedIn = str(config_file3) assert expectedIn in results assert str(sample_yaml_config) in results assert str(sample_json_config) in results
def test_find_config_filetype_string(config_dir, sample_yaml_config, sample_json_config): configs = config.find_config_files(path=[str(config_dir)], match=sample_yaml_config.purebasename, filetype='yaml') assert str(sample_yaml_config) in configs assert str(sample_json_config) not in configs configs = config.find_config_files(path=[str(config_dir)], match=sample_yaml_config.purebasename, filetype='json') assert str(sample_yaml_config) not in configs assert str(sample_json_config) not in configs configs = config.find_config_files(path=[str(config_dir)], match='repos*', filetype='json') assert str(sample_yaml_config) not in configs assert str(sample_json_config) in configs configs = config.find_config_files(path=[str(config_dir)], match='repos*', filetype='*') assert str(sample_yaml_config) in configs assert str(sample_json_config) in configs
def test_find_config_filetype_string( config_dir, sample_yaml_config, sample_json_config ): configs = config.find_config_files( path=[str(config_dir)], match=sample_yaml_config.purebasename, filetype='yaml' ) assert str(sample_yaml_config) in configs assert str(sample_json_config) not in configs configs = config.find_config_files( path=[str(config_dir)], match=sample_yaml_config.purebasename, filetype='json' ) assert str(sample_yaml_config) not in configs assert str(sample_json_config) not in configs configs = config.find_config_files( path=[str(config_dir)], match='repos*', filetype='json' ) assert str(sample_yaml_config) not in configs assert str(sample_json_config) in configs configs = config.find_config_files( path=[str(config_dir)], match='repos*', filetype='*' ) assert str(sample_yaml_config) in configs assert str(sample_json_config) in configs
def test_find_config_filetype_list( config_dir, sample_yaml_config, sample_json_config ): configs = config.find_config_files( path=[str(config_dir)], match=['repos*'], filetype=['*'], ) assert str(sample_yaml_config) in configs assert str(sample_json_config) in configs configs = config.find_config_files( path=[str(config_dir)], match=['repos*'], filetype=['json', 'yaml'], ) assert str(sample_yaml_config) in configs assert str(sample_json_config) in configs configs = config.find_config_files( path=[str(config_dir)], filetype=['json', 'yaml'], ) assert str(sample_yaml_config) in configs assert str(sample_json_config) in configs
def test_find_config_match_list( config_dir, sample_yaml_config, sample_json_config ): configs = config.find_config_files( path=[str(config_dir)], match=[ sample_yaml_config.purebasename, sample_json_config.purebasename ] ) assert str(sample_yaml_config) in configs assert str(sample_json_config) in configs configs = config.find_config_files( path=[str(config_dir)], match=[sample_yaml_config.purebasename] ) assert str(sample_yaml_config) in configs assert len([c for c in configs if str(sample_yaml_config) in c]) == 1 assert str(sample_json_config) not in configs assert len([c for c in configs if str(sample_json_config) in c]) == 0
def test_find_config_path_list( config_dir, sample_yaml_config, sample_json_config ): configs = config.find_config_files(path=[str(config_dir)]) assert str(sample_yaml_config) in configs assert str(sample_json_config) in configs
def test_find_config_path_string( config_dir, sample_yaml_config, sample_json_config ): configs = config.find_config_files(path=str(config_dir)) assert str(sample_yaml_config) in configs assert str(sample_json_config) in configs
def test_find_config_match_list(config_dir, sample_yaml_config, sample_json_config): configs = config.find_config_files( path=[str(config_dir)], match=[ sample_yaml_config.purebasename, sample_json_config.purebasename ], ) assert str(sample_yaml_config) in configs assert str(sample_json_config) in configs configs = config.find_config_files(path=[str(config_dir)], match=[sample_yaml_config.purebasename]) assert str(sample_yaml_config) in configs assert len([c for c in configs if str(sample_yaml_config) in c]) == 1 assert str(sample_json_config) not in configs assert len([c for c in configs if str(sample_json_config) in c]) == 0
def test_find_config_filetype_list(config_dir, sample_yaml_config, sample_json_config): configs = config.find_config_files(path=[str(config_dir)], match=['repos*'], filetype=['*']) assert str(sample_yaml_config) in configs assert str(sample_json_config) in configs configs = config.find_config_files(path=[str(config_dir)], match=['repos*'], filetype=['json', 'yaml']) assert str(sample_yaml_config) in configs assert str(sample_json_config) in configs configs = config.find_config_files(path=[str(config_dir)], filetype=['json', 'yaml']) assert str(sample_yaml_config) in configs assert str(sample_json_config) in configs
def test_merge_nested_dict(tmpdir, config_dir): config1 = config_dir.join('repoduplicate1.yaml') config1.write(loadfixture('repoduplicate1.yaml')) config2 = config_dir.join('repoduplicate2.yaml') config2.write(loadfixture('repoduplicate2.yaml')) # Duplicate path + name with different repo URL / remotes raises. configs = config.find_config_files(path=str(config_dir), match="repoduplicate[1-2]") assert str(config1) in configs assert str(config2) in configs with pytest.raises(Exception): config.load_configs(configs)
def test_find_config_include_home_configs(tmpdir, config_dir, sample_yaml_config, sample_json_config): with EnvironmentVarGuard() as env: env.set("HOME", str(tmpdir)) configs = config.find_config_files(path=[str(config_dir)], match='*', include_home=True) assert str(sample_yaml_config) in configs assert str(sample_json_config) in configs config_file3 = tmpdir.join('.vcspull.json') config_file3.write('') results = config.find_config_files(path=[str(config_dir)], match='*', include_home=True) expectedIn = str(config_file3) assert expectedIn in results assert str(sample_yaml_config) in results assert str(sample_json_config) in results
def test_relative_dir(tmpdir): arbitrary_dir = tmpdir.join('moo') arbitrary_dir.mkdir() arbitrary_dir.join('rel.yaml').write(""" ./relativedir: docutils: svn+http://svn.code.sf.net/p/docutils/code/trunk """) configs = config.find_config_files(path=str(arbitrary_dir)) repos = config.load_configs(configs, str(arbitrary_dir)) assert str(arbitrary_dir.join('relativedir')) == repos[0]['parent_dir'] assert str(arbitrary_dir.join('relativedir', 'docutils')) == repos[0]['repo_dir']
def test_merge_nested_dict(tmpdir, config_dir): config1 = config_dir.join('repoduplicate1.yaml') config1.write(loadfixture('repoduplicate1.yaml')) config2 = config_dir.join('repoduplicate2.yaml') config2.write(loadfixture('repoduplicate2.yaml')) # Duplicate path + name with different repo URL / remotes raises. configs = config.find_config_files(path=str(config_dir), match="repoduplicate[1-2]") assert str(config1) in configs assert str(config2) in configs with pytest.raises(Exception): config.load_configs(configs)
def test_relative_dir(tmpdir): arbitrary_dir = tmpdir.join('moo') arbitrary_dir.mkdir() arbitrary_dir.join('rel.yaml').write( """ ./relativedir: docutils: svn+http://svn.code.sf.net/p/docutils/code/trunk """ ) configs = config.find_config_files(path=str(arbitrary_dir)) repos = config.load_configs(configs, str(arbitrary_dir)) assert str(arbitrary_dir.join('relativedir')) == repos[0]['parent_dir'] assert str(arbitrary_dir.join('relativedir', 'docutils')) == repos[0]['repo_dir']
def test_find_config_match_string( config_dir, sample_yaml_config, sample_json_config ): configs = config.find_config_files( path=str(config_dir), match=sample_yaml_config.purebasename ) assert str(sample_yaml_config) in configs assert str(sample_json_config) not in configs configs = config.find_config_files( path=[str(config_dir)], match=sample_json_config.purebasename ) assert str(sample_yaml_config) not in configs assert str(sample_json_config) in configs configs = config.find_config_files( path=[str(config_dir)], match='randomstring' ) assert str(sample_yaml_config) not in configs assert str(sample_json_config) not in configs configs = config.find_config_files( path=[str(config_dir)], match='*' ) assert str(sample_yaml_config) in configs assert str(sample_json_config) in configs configs = config.find_config_files( path=[str(config_dir)], match='repos*' ) assert str(sample_yaml_config) in configs assert str(sample_json_config) in configs configs = config.find_config_files( path=[str(config_dir)], match='repos[1-9]*' ) assert len([c for c in configs if str(sample_yaml_config) in c]) == 1 assert str(sample_yaml_config) in configs assert str(sample_json_config) in configs
def test_find_config_match_string(config_dir, sample_yaml_config, sample_json_config): configs = config.find_config_files(path=str(config_dir), match=sample_yaml_config.purebasename) assert str(sample_yaml_config) in configs assert str(sample_json_config) not in configs configs = config.find_config_files(path=[str(config_dir)], match=sample_json_config.purebasename) assert str(sample_yaml_config) not in configs assert str(sample_json_config) in configs configs = config.find_config_files(path=[str(config_dir)], match='randomstring') assert str(sample_yaml_config) not in configs assert str(sample_json_config) not in configs configs = config.find_config_files(path=[str(config_dir)], match='*') assert str(sample_yaml_config) in configs assert str(sample_json_config) in configs configs = config.find_config_files(path=[str(config_dir)], match='repos*') assert str(sample_yaml_config) in configs assert str(sample_json_config) in configs configs = config.find_config_files(path=[str(config_dir)], match='repos[1-9]*') assert len([c for c in configs if str(sample_yaml_config) in c]) == 1 assert str(sample_yaml_config) in configs assert str(sample_json_config) in configs
def test_find_config_path_string(config_dir, sample_yaml_config, sample_json_config): configs = config.find_config_files(path=str(config_dir)) assert str(sample_yaml_config) in configs assert str(sample_json_config) in configs
def test_find_config_path_list(config_dir, sample_yaml_config, sample_json_config): configs = config.find_config_files(path=[str(config_dir)]) assert str(sample_yaml_config) in configs assert str(sample_json_config) in configs