def test_find_config_files(self, tmp_path): """Test find_config_files.""" bad_path = tmp_path / 'bad_path' bad_path.mkdir() # tmp_path.stem good_config_paths = [ tmp_path / '_t3sT.yaml', tmp_path / '_t3sT.yml', tmp_path / '01-config.yaml', tmp_path / '01-config.yml', tmp_path / 'TeSt_02.yaml', tmp_path / 'TeSt_02.yml', tmp_path / 'test.config.yaml', tmp_path / 'test.config.yml' ] bad_config_paths = [ tmp_path / '.anything.yaml', tmp_path / '.gitlab-ci.yml', tmp_path / 'docker-compose.yml', bad_path / '00-invalid.yml' ] for config_path in good_config_paths + bad_config_paths: # python2 Path.write_text requires unicode config_path.write_text(u'') # support python < 3.6 result = CFNgin.find_config_files(sys_path=str(tmp_path)) expected = sorted( [str(config_path) for config_path in good_config_paths]) assert result == expected config_01 = tmp_path / '01-config.yml' result = CFNgin.find_config_files( sys_path=str(config_01) # support python < 3.6 ) assert result == [str(config_01)] # support python < 3.6 result = CFNgin.find_config_files() assert not result
def test_find_config_files(self, tmp_path): """Test find_config_files.""" bad_path = tmp_path / "bad_path" bad_path.mkdir() good_config_paths = [ tmp_path / "_t3sT.yaml", tmp_path / "_t3sT.yml", tmp_path / "01-config.yaml", tmp_path / "01-config.yml", tmp_path / "TeSt_02.yaml", tmp_path / "TeSt_02.yml", tmp_path / "test.config.yaml", tmp_path / "test.config.yml", ] bad_config_paths = [ tmp_path / ".anything.yaml", tmp_path / ".gitlab-ci.yml", tmp_path / "bitbucket-pipelines.yml", tmp_path / "buildspec.yml", tmp_path / "docker-compose.yml", bad_path / "00-invalid.yml", ] for config_path in good_config_paths + bad_config_paths: # python2 Path.write_text requires unicode config_path.write_text(u"") # support python < 3.6 result = CFNgin.find_config_files(sys_path=str(tmp_path)) expected = sorted([str(config_path) for config_path in good_config_paths]) assert result == expected config_01 = tmp_path / "01-config.yml" result = CFNgin.find_config_files( sys_path=str(config_01) # support python < 3.6 ) assert result == [str(config_01)] # support python < 3.6 result = CFNgin.find_config_files() assert not result