示例#1
0
def test_copy_auto_no_existing_file(mocker):
    symlink_mock = mocker.patch("conda_env_tracker.gateways.io.os.symlink")
    mocker.patch("conda_env_tracker.gateways.io.Path.unlink")
    mocker.patch("conda_env_tracker.gateways.io.Path.exists",
                 mocker.Mock(return_value=False))

    io.link_auto()

    symlink_mock.assert_called_once_with(io.SHELL_FILE,
                                         io.USER_CET_DIR / io.SHELL_FILE.name)
示例#2
0
def test_copy_auto_with_same_existing_file(mocker):
    symlink_mock = mocker.patch("conda_env_tracker.gateways.io.os.symlink")
    mocker.patch("conda_env_tracker.gateways.io.Path.unlink")
    mocker.patch(
        "conda_env_tracker.gateways.io.Path.read_text",
        mocker.Mock(return_value="string"),
    )
    mocker.patch("conda_env_tracker.gateways.io.Path.exists",
                 mocker.Mock(return_value=True))
    prompt_mock = mocker.patch("conda_env_tracker.utils.prompt_yes_no")

    io.link_auto()

    prompt_mock.assert_not_called()
    symlink_mock.assert_not_called()
示例#3
0
def test_copy_auto_with_different_existing_file(mocker, response):
    package_shell_file = io.SHELL_FILE
    expected_contents = package_shell_file.read_text()

    symlink_mock = mocker.patch("conda_env_tracker.gateways.io.os.symlink")
    mocker.patch("conda_env_tracker.gateways.io.Path.unlink")
    mocker.patch(
        "conda_env_tracker.gateways.io.Path.read_text",
        mocker.Mock(side_effect=[expected_contents, "user file"]),
    )
    mocker.patch("conda_env_tracker.gateways.io.Path.exists",
                 mocker.Mock(return_value=True))
    mocker.patch("conda_env_tracker.utils.prompt_yes_no",
                 mocker.Mock(return_value=response))

    io.link_auto()

    if response:
        symlink_mock.assert_called_once_with(
            io.SHELL_FILE, io.USER_CET_DIR / io.SHELL_FILE.name)
    else:
        symlink_mock.assert_not_called()
示例#4
0
def setup_auto_shell_file() -> None:
    """Setup the automatic use of conda env tracker push/pull when navigating to git repos"""
    # pylint: disable=redefined-outer-name
    link_auto()
示例#5
0
def setup_auto(activate: bool = False, sync: bool = False, yes: bool = False) -> None:
    """Setup the automatic use of cet push/pull when navigating to git repos"""
    # pylint: disable=redefined-outer-name
    link_auto()
    add_auto_to_bash_config_file(activate=activate, sync=sync, yes=yes)