Exemplo n.º 1
0
def test_username_error(git_mock, monkeypatch):
    fake_git = Mock(side_effect=exceptions.ShellCommandException)
    monkeypatch.setattr(info.shell, "git", fake_git)
    # on windows getpass might fail
    monkeypatch.setattr(info.getpass, "getuser", Mock(side_effect=SystemError))
    with pytest.raises(exceptions.GitNotConfigured):
        info.username()
Exemplo n.º 2
0
def test_username_with_no_git(nogit_mock):  # noqa
    username = info.username()
    assert isinstance(username, string_types)
    assert getpass.getuser() == username
Exemplo n.º 3
0
def test_username_with_git(git_mock):  # noqa
    username = info.username()
    assert isinstance(username, string_types)
    assert len(username) > 0
Exemplo n.º 4
0
def test_username_with_no_git(nogit_mock):
    username = info.username()
    assert isinstance(username, str)
    assert getpass.getuser() == username
Exemplo n.º 5
0
def test_username_with_no_git(nogit_mock):
    username = info.username()
    assert isinstance(username, str)
    assert getpass.getuser() == username
Exemplo n.º 6
0
def test_username_with_git(git_mock):
    username = info.username()
    assert isinstance(username, str)
    assert len(username) > 0
Exemplo n.º 7
0
def test_username_with_git(git_mock):
    username = info.username()
    assert isinstance(username, str)
    assert len(username) > 0
Exemplo n.º 8
0
def test_username_with_no_git(nogit_mock):  # noqa
    username = info.username()
    assert isinstance(username, string_types)
    assert getpass.getuser() == username
Exemplo n.º 9
0
def test_username_with_git(git_mock):  # noqa
    username = info.username()
    assert isinstance(username, string_types)
    assert len(username) > 0
Exemplo n.º 10
0
def test_username():
    username = info.username()
    print(type(username))
    assert isinstance(username, str)
    assert len(username) > 0
Exemplo n.º 11
0
def main():
    """Interactive Python/DataScience project template setup using PyScaffold
    """

    license_choices = templates.licenses.keys()
    extensions = []

    click.echo(
        click.style(
            "\nPyScaffold-Interactive - A tool to interactively " +
            "create python project templates using PyScaffold\n",
            fg="green",
        ))

    project_name = prompt_text("Enter your project name ", default="PyProject")

    author = prompt_text("Package author name ", default=info.username())

    email = prompt_text("Author email", default=info.email())

    url = prompt_text(
        "Project URL",
        default="https://github.com/SarthakJariwala/PyScaffold-Interactive",
    )

    description = prompt_text(
        "Enter package description\n",
        default="Generated using PyScaffold and PyScaffold-Interactive",
    )

    license = prompt_choice("Choose License\n", license_choices,
                            default="mit").lower()

    is_data_sci_proj = prompt_choice("Is this a DataScience project?",
                                     ["y", "n"],
                                     default="n").lower()

    if is_data_sci_proj == "y":
        if sys.platform == "win32":
            data_sci_cmds = ["cmd", "/c", shutil.which("putup")]
        else:
            data_sci_cmds = ["putup"]
        data_sci_cmds.append("{}".format(project_name))
        data_sci_cmds.append("--description")
        data_sci_cmds.append("{}".format(description))
        data_sci_cmds.append("--url")
        data_sci_cmds.append("{}".format(url))
        data_sci_cmds.append("--license")
        data_sci_cmds.append("{}".format(license))
        data_sci_cmds.append("--dsproject")

    make_tox = prompt_choice(
        "Generate config files for automated testing using tox? ",
        ["y", "n"],
        default="y",
    ).lower()

    if make_tox == "y":
        if is_data_sci_proj == "y":
            data_sci_cmds.append("--tox")
        else:
            extensions.append(Tox("tox"))

    create_travis = prompt_choice(
        "Generate config and script files for Travis CI.? ", ["y", "n"],
        default="y").lower()

    if create_travis == "y":
        if is_data_sci_proj == "y":
            data_sci_cmds.append("--travis")
        else:
            extensions.append(Travis("travis"))

    # only ask for pre-commit if not datascience project, auto-yes for datasci project
    if is_data_sci_proj == "n":
        create_pre_commit = prompt_choice(
            "Generate pre-commit config? [Recommended] ", ["y", "n"],
            default="y").lower()

        if create_pre_commit == "y":
            extensions.append(PreCommit("pre-commit"))

    if is_data_sci_proj == "y":
        # setup datascience project using putup
        subprocess.call(data_sci_cmds)
    else:
        create_project(
            project=project_name,
            license=license,
            extensions=extensions,
            opts={
                "description": "{}".format(description),
                "author": "{}".format(author),
                "email": "{}".format(email),
                "url": "{}".format(url),
            },
        )

    click.echo(
        click.style("\nSuccess! {} created. Lets code!".format(project_name),
                    fg="green"))

    click.echo(
        click.style("\nAll putup commands are also available. For help - ",
                    fg="green") + click.style("'putup --help'", fg="red"))