def test_is_vcs_installed(mocker, which_return, result): mocker.patch( 'cookiecutter.vcs.which', autospec=True, return_value=which_return ) assert vcs.is_vcs_installed('git') == result
def prompt_user(): # Prompt user for input for key, value in defaults.items(): if not key.startswith("_"): if isinstance(value, list): defaults[key] = prompt.read_user_choice(key, value) elif isinstance(value, str): defaults[key] = prompt.read_user_variable(key, value) # adjust defaults based on special conditions if key.endswith("import_type"): defaults["import"] = defaults["installed"][defaults[key]] elif key.endswith("import"): defaults["project_name"] = defaults[key] defaults["repository_name"] = ( defaults[key].replace(" ", "_") + "_Rainmeter_Skin" ) # promt user to pick skin to load if importing an installed skin if ( defaults["import_type"] == "Skin" and defaults["import"] != "Create a new skin" ): # now ask the user which skin to load on-install skin_configs = [] for dirpath, _, filenames in os.walk( defaults["_skins_path"] + os.sep + defaults[key] ): for f in filenames: if f.endswith(".ini"): skin_configs.append( dirpath.replace( defaults["_skins_path"] + os.sep, "", ) + os.sep + f ) defaults["_load_skin"] = prompt.read_user_choice( "skin to load", skin_configs ) elif key.endswith("project_name"): defaults["repository_name"] = ( defaults[key].replace(" ", "_") + "_Rainmeter_Skin" ) elif key.endswith("req_windows_version"): defaults["req_windows_version"] = defaults["_windows_version_alias"][defaults[key]] elif key.endswith("req_rainmeter_version"): # restrict windows version based on rainmeter version if float(defaults[key][:3]) >= 4.0: defaults["req_windows_version"].remove("Windows XP") defaults["req_windows_version"].remove("Windows Vista") if vcs.is_vcs_installed("git"): print("git is installed") init_commit = prompt.read_user_yes_no("Create initial commit? (y/n)", "y") if isinstance(init_commit, str): init_commit = True if init_commit == "y" else False defaults["_init_commit"] = init_commit
def test_non_existing_repo_type(self): self.assertFalse(vcs.is_vcs_installed("stringthatisntashellcommand"))
def test_existing_repo_type(self): self.assertTrue(vcs.is_vcs_installed("git"), )
def test_is_vcs_installed(mocker, which_return, result): mocker.patch("cookiecutter.vcs.which", autospec=True, return_value=which_return) assert vcs.is_vcs_installed("git") == result
def test_is_vcs_installed(mocker, which_return, result): """Verify `is_vcs_installed` function correctly handles `which` answer.""" mocker.patch('cookiecutter.vcs.which', autospec=True, return_value=which_return) assert vcs.is_vcs_installed('git') == result
def test_non_existing_repo_type(self): self.assertFalse( vcs.is_vcs_installed("stringthatisntashellcommand") )
def test_existing_repo_type(self): self.assertTrue( vcs.is_vcs_installed("git"), )
def test_non_existing_repo_type(): assert not vcs.is_vcs_installed("stringthatisntashellcommand")
def test_existing_repo_type(): assert vcs.is_vcs_installed("git")