Beispiel #1
0
def test_email_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.email()
Beispiel #2
0
def test_email_with_nogit(nogit_mock):  # noqa
    email = info.email()
    assert socket.gethostname() == email.split("@")[1]
Beispiel #3
0
def test_email_with_git(git_mock):  # noqa
    email = info.email()
    assert "@" in email
Beispiel #4
0
def test_email_with_nogit(nogit_mock):
    email = info.email()
    assert socket.gethostname() == email.split("@")[1]
Beispiel #5
0
def test_email_with_git(git_mock):
    email = info.email()
    assert "@" in email
def test_email():
    email = info.email()
    assert "@" in email
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"))