Exemplo n.º 1
0
def test_make_structure_without_vagrant():
    args = ["project", "-p", "package", "-d", "description"]
    opts = cli.parse_args(args)
    opts = cli.get_default_opts(opts['project'], **opts)
    struct = structure.make_structure(opts)
    assert isinstance(struct, dict)
    assert "vagrant" not in struct["project"]
Exemplo n.º 2
0
def test_pretend_move_old_package(tmpfolder, caplog, isolated_logger):
    # Given a package is already created without namespace
    create_project(project="proj", package="my_pkg")

    opts = parse_args(
        ["proj", "-p", "my_pkg", "--namespace", "my.ns", "--pretend"])
    opts = process_opts(opts)
    logger.reconfigure(opts)
    struct = dict(proj={"src": {"my_pkg": {"file.py": ""}}})

    # when 'pretend' option is passed,
    struct, opts = get_default_options(struct, opts)
    struct, opts = enforce_namespace_options(struct, opts)
    struct, opts = move_old_package(struct, opts)

    # then nothing should happen,
    assert tmpfolder.join("proj/src/my_pkg/__init__.py").check()
    assert not tmpfolder.join("proj/src/my/ns").check()

    # something should be logged,
    log = caplog.text
    expected_log = ("move", "my_pkg", "to", str(Path("my/ns")))
    for text in expected_log:
        assert text in log

    # but user should see no warning,
    unexpected_warnings = (
        "A folder",
        "exists in the project directory",
        "a namespace option was passed",
        "Please make sure",
    )
    for text in unexpected_warnings:
        assert text not in log
Exemplo n.º 3
0
def test_pretend_move_old_package(tmpfolder, caplog, isolated_logger):
    # Given a package is already created without namespace
    create_project(project="proj", package="my_pkg")

    opts = parse_args(
        ["proj", "-p", "my_pkg", "--namespace", "my.ns", "--pretend"])
    opts = process_opts(opts)
    configure_logger(opts)
    struct = dict(proj={'src': {'my_pkg': {'file.py': ''}}})

    # when 'pretend' option is passed,
    struct, opts = get_default_options(struct, opts)
    struct, opts = enforce_namespace_options(struct, opts)
    struct, opts = move_old_package(struct, opts)

    # then nothing should happen,
    assert tmpfolder.join("proj/src/my_pkg/__init__.py").check()
    assert not tmpfolder.join("proj/src/my/ns").check()

    # something should be logged,
    log = caplog.text
    expected_log = ('move', 'my_pkg', 'to', 'my/ns')
    for text in expected_log:
        assert text in log

    # but user should see no warning,
    unexpected_warnings = ('A folder', 'exists in the project directory',
                           'a namespace option was passed', 'Please make sure')
    for text in unexpected_warnings:
        assert text not in log
Exemplo n.º 4
0
def test_define_structure():
    args = ["project", "-p", "package", "-d", "description"]
    opts = cli.parse_args(args)
    opts = api.bootstrap_options(opts)
    _, opts = actions.get_default_options({}, opts)
    struct, _ = structure.define_structure({}, opts)
    assert isinstance(struct, dict)
Exemplo n.º 5
0
def test_project_with_wrong_setup(tmpfolder):
    os.mkdir("my_project")
    open("my_project/setup.py", "a").close()
    args = ["my_project"]
    opts = cli.parse_args(args)
    with pytest.raises(FileNotFoundError):
        info.project(opts)
Exemplo n.º 6
0
def test_project_with_no_setup(tmpfolder):
    os.mkdir("my_project")
    args = ["my_project"]
    opts = cli.parse_args(args)
    opts = cli.process_opts(opts)
    with pytest.raises(FileNotFoundError):
        info.project(opts)
Exemplo n.º 7
0
def test_pretend_move_old_package(tmpfolder, caplog, isolated_logger):
    # Given a package is already created without namespace
    create_project(project="proj", package="my_pkg")

    opts = parse_args(
        ["proj", "-p", "my_pkg", "--namespace", "my.ns", "--pretend"])
    opts = process_opts(opts)
    configure_logger(opts)
    struct = dict(proj={'src': {'my_pkg': {'file.py': ''}}})

    # when 'pretend' option is passed,
    struct, opts = get_default_options(struct, opts)
    struct, opts = enforce_namespace_options(struct, opts)
    struct, opts = move_old_package(struct, opts)

    # then nothing should happen,
    assert tmpfolder.join("proj/src/my_pkg/__init__.py").check()
    assert not tmpfolder.join("proj/src/my/ns").check()

    # something should be logged,
    log = caplog.text
    expected_log = ('move', 'my_pkg', 'to', 'my/ns')
    for text in expected_log:
        assert text in log

    # but user should see no warning,
    unexpected_warnings = ('A folder', 'exists in the project directory',
                           'a namespace option was passed', 'Please make sure')
    for text in unexpected_warnings:
        assert text not in log
Exemplo n.º 8
0
def test_project_with_wrong_setup(tmpdir):  # noqa
    os.mkdir("my_project")
    open("my_project/setup.py", 'a').close()
    args = ["my_project"]
    args = cli.parse_args(args)
    with pytest.raises(RuntimeError):
        info.project(args)
Exemplo n.º 9
0
def test_add_custom_extension(tmpfolder):
    args = [EXT_FLAG, "my_project", "-p", "my_package"]
    opts = parse_args(args)
    opts = process_opts(opts)
    create_project(opts)

    assert path_exists("my_project/src/my_package/__init__.py")
Exemplo n.º 10
0
def test_project_with_wrong_setup(tmpdir):  # noqa
    os.mkdir("my_project")
    open("my_project/setup.py", 'a').close()
    args = ["my_project"]
    args = cli.parse_args(args)
    with pytest.raises(RuntimeError):
        info.project(args)
def test_pre_commit(tmpfolder):
    args = ["--custom-extension", "pyscaffoldext-some_extension"]

    opts = parse_args(args)
    create_project(opts)

    assert path_exists("pyscaffoldext-some_extension/.pre-commit-config.yaml")
def test_no_skeleton(tmpfolder):
    args = ["--custom-extension", "pyscaffoldext-some_extension"]

    opts = parse_args(args)
    create_project(opts)

    assert not path_exists("pyscaffoldext-some_extension/src/pyscaffoldext/"
                           "some_extension/skeleton.py")
Exemplo n.º 13
0
def test_make_structure_with_tox():
    args = ["project", "-p", "package", "-d", "description", "--with-tox"]
    opts = cli.parse_args(args)
    opts = cli.get_default_opts(opts['project'], **opts)
    struct = structure.make_structure(opts)
    assert isinstance(struct, dict)
    assert "tox.ini" in struct["project"]
    assert isinstance(struct["project"]["tox.ini"], six.string_types)
Exemplo n.º 14
0
def test_parse_license_finds_best_fit():
    examples = {
        "apache": "Apache-2.0",
        "artistic": "Artistic-2.0",
        "affero": "AGPL-3.0-only",
        "eclipse": "EPL-1.0",
        "new-bsd": "BSD-3-Clause",
        "mozilla": "MPL-2.0",
        "gpl3": "GPL-3.0-only",
    }

    for key, value in examples.items():
        opts = cli.parse_args(["my-project", "--license", key])
        assert opts["license"] == value

    # option not passed
    assert "license" not in cli.parse_args(["my_project"])
Exemplo n.º 15
0
def test_make_structure_with_pre_commit_hooks():
    args = [
        "project", "-p", "package", "-d", "description", "--with-pre-commit"
    ]
    opts = cli.parse_args(args)
    opts = cli.get_default_opts(opts['project'], **opts)
    struct = structure.make_structure(opts)
    assert isinstance(struct, dict)
    assert ".pre-commit-config.yaml" in struct["project"]
Exemplo n.º 16
0
def test_make_structure_without_vagrant():
    args = ["project",
            "-p", "package",
            "-d", "description"]
    opts = cli.parse_args(args)
    opts = cli.get_default_opts(opts['project'], **opts)
    struct = structure.make_structure(opts)
    assert isinstance(struct, dict)
    assert "vagrant" not in struct["project"]
def test_add_custom_extension_with_namespace(tmpfolder):
    # we expect the second namespace to be just ignored
    args = [
        "--namespace", "test", "--custom-extension",
        "pyscaffoldext-some_extension"
    ]

    opts = parse_args(args)
    with pytest.raises(NamespaceError):
        create_project(opts)
Exemplo n.º 18
0
def test_make_structure_with_pre_commit_hooks():
    args = ["project",
            "-p", "package",
            "-d", "description",
            "--with-pre-commit"]
    opts = cli.parse_args(args)
    opts = cli.get_default_opts(opts['project'], **opts)
    struct = structure.make_structure(opts)
    assert isinstance(struct, dict)
    assert ".pre-commit-config.yaml" in struct["project"]
Exemplo n.º 19
0
def test_project_without_args(tmpfolder):
    old_args = ["my_project", "-u", "http://www.blue-yonder.com/",
                "-d", "my description"]
    cli.main(old_args)
    args = ["my_project"]
    opts = cli.parse_args(args)
    new_opts = info.project(opts)
    assert new_opts['url'] == "http://www.blue-yonder.com/"
    assert new_opts['package'] == "my_project"
    assert new_opts['license'] == "mit"
    assert new_opts['description'] == "my description"
Exemplo n.º 20
0
def test_make_structure_with_vagrant():
    args = ["project",
            "-p", "package",
            "-d", "description",
            "--with-vagrant", "debian/jessie64"]
    opts = cli.parse_args(args)
    opts = cli.get_default_opts(opts['project'], **opts)
    struct = structure.make_structure(opts)
    assert isinstance(struct, dict)
    assert "Vagrantfile" in struct["project"]["vagrant"]
    assert isinstance(struct["project"]["vagrant"]["Vagrantfile"], six.string_types)
Exemplo n.º 21
0
def test_project_with_args(tmpdir):  # noqa
    old_args = ["my_project", "-u", "http://www.blue-yonder.com/",
                "-d", "my description"]
    cli.main(old_args)
    args = ["my_project", "-u", "http://www.google.com/",
            "-d", "other description"]
    opts = cli.parse_args(args)
    new_opts = info.project(opts)
    assert new_opts['url'] == "http://www.blue-yonder.com/"
    assert new_opts['package'] == "my_project"
    assert new_opts['description'] == "my description"
Exemplo n.º 22
0
def test_make_structure_with_tox():
    args = ["project",
            "-p", "package",
            "-d", "description",
            "--with-tox"]
    opts = cli.parse_args(args)
    opts = cli.get_default_opts(opts['project'], **opts)
    struct = structure.make_structure(opts)
    assert isinstance(struct, dict)
    assert "tox.ini" in struct["project"]
    assert isinstance(struct["project"]["tox.ini"], six.string_types)
Exemplo n.º 23
0
def test_project_with_args(tmpdir):  # noqa
    old_args = ["my_project", "-u", "http://www.blue-yonder.com/",
                "-d", "my description"]
    cli.main(old_args)
    args = ["my_project", "-u", "http://www.google.com/",
            "-d", "other description"]
    opts = cli.parse_args(args)
    new_opts = info.project(opts)
    assert new_opts['url'] == "http://www.blue-yonder.com/"
    assert new_opts['package'] == "my_project"
    assert new_opts['description'] == "my description"
Exemplo n.º 24
0
def test_add_namespace():
    args = ["project", "-p", "package", "--namespace", "com.blue_yonder"]
    opts = parse_args(args)
    opts['namespace'] = prepare_namespace(opts['namespace'])
    struct = {"project": {"src": {"package": {"file1": "Content"}}}}
    ns_struct, _ = add_namespace(struct, opts)
    ns_pkg_struct = ns_struct["project"]["src"]
    assert ["project"] == list(ns_struct.keys())
    assert "package" not in list(ns_struct.keys())
    assert ["com"] == list(ns_pkg_struct.keys())
    assert {"blue_yonder", "__init__.py"} == set(ns_pkg_struct["com"].keys())
    assert "package" in list(ns_pkg_struct["com"]["blue_yonder"].keys())
Exemplo n.º 25
0
def test_make_structure_with_vagrant():
    args = [
        "project", "-p", "package", "-d", "description", "--with-vagrant",
        "debian/jessie64"
    ]
    opts = cli.parse_args(args)
    opts = cli.get_default_opts(opts['project'], **opts)
    struct = structure.make_structure(opts)
    assert isinstance(struct, dict)
    assert "Vagrantfile" in struct["project"]["vagrant"]
    assert isinstance(struct["project"]["vagrant"]["Vagrantfile"],
                      six.string_types)
Exemplo n.º 26
0
def test_add_namespace():
    args = ["project", "-p", "package", "--with-namespace", "com.blue_yonder"]
    opts = cli.parse_args(args)
    opts['namespace'] = utils.prepare_namespace(opts['namespace'])
    struct = {"project": {"package": {"file1": "Content"}}}
    ns_struct = structure.add_namespace(opts, struct)
    assert ["project"] == list(ns_struct.keys())
    assert "package" not in list(ns_struct.keys())
    assert ["com"] == list(ns_struct["project"].keys())
    assert {"blue_yonder",
            "__init__.py"} == set(ns_struct["project"]["com"].keys())
    assert "package" in list(ns_struct["project"]["com"]["blue_yonder"].keys())
def test_entry_point(tmpfolder):
    args = ["--custom-extension", "pyscaffoldext-some_extension"]

    opts = parse_args(args)
    create_project(opts)
    assert path_exists("pyscaffoldext-some_extension/setup.cfg")

    config_updater = ConfigUpdater()
    with open("pyscaffoldext-some_extension/setup.cfg") as f:
        config_updater.read_file(f)
    entry_point = config_updater.get("options.entry_points",
                                     "pyscaffold.cli").value
    assert entry_point == "\nsome_extension = pyscaffoldext." \
                          "some_extension.extension:SomeExtension"
Exemplo n.º 28
0
def test_pretend_create_project_with_django(tmpfolder, caplog):
    # Given options with the django extension,
    opts = parse_args([PROJ_NAME, '--pretend', '--django'])

    # when the project is created,
    create_project(opts)

    # then files should exist
    assert not path_exists(PROJ_NAME)
    for path in DJANGO_FILES:
        assert not path_exists(path)

    # but activities should be logged
    assert re.search(r'run\s+django', caplog.text)
Exemplo n.º 29
0
def test_pretend_create_project_with_django(tmpfolder, caplog):
    # Given options with the django extension,
    opts = parse_args([PROJ_NAME, '--pretend', '--django'])

    # when the project is created,
    create_project(opts)

    # then files should exist
    assert not path_exists(PROJ_NAME)
    for path in DJANGO_FILES:
        assert not path_exists(path)

    # but activities should be logged
    assert re.search(r'run\s+django', caplog.text)
Exemplo n.º 30
0
def test_add_namespace():
    args = ["project",
            "-p", "package",
            "--namespace", "com.blue_yonder"]
    opts = parse_args(args)
    opts['namespace'] = prepare_namespace(opts['namespace'])
    struct = {"project": {"src": {"package": {"file1": "Content"}}}}
    ns_struct, _ = add_namespace(struct, opts)
    ns_pkg_struct = ns_struct["project"]["src"]
    assert ["project"] == list(ns_struct.keys())
    assert "package" not in list(ns_struct.keys())
    assert ["com"] == list(ns_pkg_struct.keys())
    assert {"blue_yonder", "__init__.py"} == set(ns_pkg_struct["com"].keys())
    assert "package" in list(ns_pkg_struct["com"]["blue_yonder"].keys())
Exemplo n.º 31
0
def test_generated_extension(tmpfolder, venv_run):
    args = ["--custom-extension", "pyscaffoldext-some_extension"]

    opts = parse_args(args)
    create_project(opts)
    with chdir("pyscaffoldext-some_extension"):
        assert '' == venv_run("flake8")
        venv_run("python setup.py install")

    venv_run("putup --some-extension the_actual_project")
    assert path_exists("the_actual_project/setup.cfg")

    with chdir("the_actual_project"):
        assert '' == venv_run("flake8")
Exemplo n.º 32
0
def test_add_namespace():
    args = ["project",
            "-p", "package",
            "--with-namespace", "com.blue_yonder"]
    opts = cli.parse_args(args)
    opts['namespace'] = utils.prepare_namespace(opts['namespace'])
    struct = {"project": {"package": {"file1": "Content"}}}
    ns_struct = structure.add_namespace(opts, struct)
    assert ["project"] == list(ns_struct.keys())
    assert "package" not in list(ns_struct.keys())
    assert ["com"] == list(ns_struct["project"].keys())
    assert {"blue_yonder", "__init__.py"} == set(
        ns_struct["project"]["com"].keys())
    assert "package" in list(ns_struct["project"]["com"]["blue_yonder"].keys())
def test_add_install_requires(tmpfolder):
    args = ["--custom-extension", "pyscaffoldext-some_extension"]

    opts = parse_args(args)
    create_project(opts)
    assert path_exists("pyscaffoldext-some_extension/setup.cfg")

    config_updater = ConfigUpdater()

    with open("pyscaffoldext-some_extension/setup.cfg") as f:
        config_updater.read_file(f)

    install_requires = config_updater.get("options", "install_requires").value

    assert "pyscaffold" in install_requires
def test_pretend_create_project_with_cookiecutter(tmpfolder, caplog):
    # Given options with the cookiecutter extension,
    opts = parse_args(
        [PROJ_NAME, '--pretend', '--cookiecutter', COOKIECUTTER_URL])

    # when the project is created,
    create_project(opts)

    # then files should exist
    assert not path_exists(PROJ_NAME)
    for path in COOKIECUTTER_FILES:
        assert not path_exists(path)

    # but activities should be logged
    assert re.search(r'run\s+cookiecutter', caplog.text)
Exemplo n.º 35
0
def test_generated_extension_flake8(tmpfolder, venv_run):
    args = [EXT_FLAG, "my_project"]
    opts = parse_args(args)
    opts = process_opts(opts)
    create_project(opts)

    with chdir("my_project"):
        assert "" == venv_run(FLAKE8)
        venv_run("python setup.py install")

    venv_run("putup {ext_flag} the_actual_project".format(ext_flag=EXT_FLAG))
    assert path_exists("the_actual_project/setup.cfg")

    with chdir("the_actual_project"):
        assert "" == venv_run(FLAKE8)
Exemplo n.º 36
0
def test_project_without_args(tmpfolder):
    old_args = [
        "my_project",
        "-u",
        "http://www.blue-yonder.com/",
        "-d",
        "my description",
    ]
    cli.main(old_args)
    args = ["my_project"]
    opts = cli.parse_args(args)
    new_opts = info.project(opts)
    assert new_opts["url"] == "http://www.blue-yonder.com/"
    assert new_opts["package"] == "my_project"
    assert new_opts["license"] == "MIT"
    assert new_opts["description"] == "my description"
Exemplo n.º 37
0
def test_pretend_create_project_with_django(tmpfolder, caplog):
    # Given options with the django extension,
    caplog.set_level(logging.INFO)
    opts = parse_args([PROJ_NAME, "--pretend", "--django"])
    opts = process_opts(opts)

    # when the project is created,
    create_project(opts)

    # then files should exist
    assert not path_exists(PROJ_NAME)
    for path in DJANGO_FILES:
        assert not path_exists(path)

    # but activities should be logged
    logs = caplog.text
    assert re.search(r"run.+django", logs)
Exemplo n.º 38
0
def test_version_of_subdir(tmpdir): # noqa
    projects = ["main_project", "inner_project"]
    for project in projects:
        opts = cli.parse_args([project])
        opts = cli.get_default_opts(opts['project'], **opts)
        struct = structure.make_structure(opts)
        structure.create_structure(struct)
        repo.init_commit_repo(project, struct)
    shutil.rmtree(os.path.join('inner_project', '.git'))
    shutil.move('inner_project', 'main_project/inner_project')
    with utils.chdir('main_project'):
        main_version = subprocess.check_output([
            'python', 'setup.py', '--version']).strip()
        with utils.chdir('inner_project'):
            inner_version = subprocess.check_output([
                'python', 'setup.py', '--version']).strip()
    assert main_version == inner_version
Exemplo n.º 39
0
def test_options_with_existing_proj_config_and_cli(with_existing_proj_config):
    # Given an existing project with a setup.cfg
    _ = with_existing_proj_config
    # When the CLI is called with no extra parameters
    opts = cli.parse_args(["--update", "."])
    opts = bootstrap_options(opts)
    _, opts = get_default_options({}, opts)

    # After all the opt processing actions are finished
    # The parameters in the old setup.py files are preserved
    assert opts["name"] == "SuperProj"
    assert opts["description"] == "some text"
    assert opts["author"] == "John Doe"
    assert opts["email"] == "*****@*****.**"
    assert opts["url"] == "www.example.com"
    assert opts["license"] == "GPL-3.0-only"
    assert opts["package"] == "super_proj"
Exemplo n.º 40
0
def test_version_of_subdir(tmpdir):  # noqa
    projects = ["main_project", "inner_project"]
    for project in projects:
        opts = cli.parse_args([project])
        opts = cli.get_default_opts(opts['project'], **opts)
        struct = structure.make_structure(opts)
        structure.create_structure(struct)
        repo.init_commit_repo(project, struct)
    shutil.rmtree(os.path.join('inner_project', '.git'))
    shutil.move('inner_project', 'main_project/inner_project')
    with utils.chdir('main_project'):
        main_version = subprocess.check_output(
            ['python', 'setup.py', '--version']).strip()
        with utils.chdir('inner_project'):
            inner_version = subprocess.check_output(
                ['python', 'setup.py', '--version']).strip()
    assert main_version == inner_version
Exemplo n.º 41
0
def test_version_of_subdir(tmpfolder):
    projects = ["main_project", "inner_project"]
    for project in projects:
        opts = cli.parse_args([project])
        _, opts = api.get_default_options({}, opts)
        struct, _ = structure.define_structure({}, opts)
        struct, _ = structure.apply_update_rules(struct, opts)
        structure.create_structure(struct, {})
        repo.init_commit_repo(project, struct)
    shutil.rmtree(os.path.join('inner_project', '.git'))
    shutil.move('inner_project', 'main_project/inner_project')
    with utils.chdir('main_project'):
        main_version = subprocess.check_output(
            ['python', 'setup.py', '--version']).strip().splitlines()[-1]
        with utils.chdir('inner_project'):
            inner_version = subprocess.check_output(
                ['python', 'setup.py', '--version']).strip().splitlines()[-1]
    assert main_version.strip() == inner_version.strip()
Exemplo n.º 42
0
def test_pretend_create_project_with_cookiecutter(tmpfolder, caplog):
    # Given options with the cookiecutter extension,
    caplog.set_level(logging.INFO)
    opts = parse_args(
        [PROJ_NAME, '--pretend', '--cookiecutter', COOKIECUTTER_URL])
    opts = process_opts(opts)

    # when the project is created,
    create_project(opts)

    # then files should exist
    assert not path_exists(PROJ_NAME)
    for path in COOKIECUTTER_FILES:
        assert not path_exists(path)

    # but activities should be logged
    logs = caplog.text
    assert re.search(r'run.+cookiecutter', logs)
Exemplo n.º 43
0
def test_version_of_subdir(tmpfolder):
    projects = ["main_project", "inner_project"]
    for project in projects:
        opts = cli.parse_args([project])
        _, opts = api.get_default_options({}, opts)
        struct, _ = structure.define_structure({}, opts)
        struct, _ = structure.apply_update_rules(struct, opts)
        structure.create_structure(struct, {})
        repo.init_commit_repo(project, struct)
    shutil.rmtree(os.path.join('inner_project', '.git'))
    shutil.move('inner_project', 'main_project/inner_project')
    with utils.chdir('main_project'):
        main_version = subprocess.check_output([
            'python', 'setup.py', '--version']).strip().splitlines()[-1]
        with utils.chdir('inner_project'):
            inner_version = subprocess.check_output([
                'python', 'setup.py', '--version']).strip().splitlines()[-1]
    assert main_version.strip() == inner_version.strip()
Exemplo n.º 44
0
def test_project_with_no_setup(tmpdir):  # noqa
    os.mkdir("my_project")
    args = ["my_project"]
    args = cli.parse_args(args)
    with pytest.raises(RuntimeError):
        info.project(args)
Exemplo n.º 45
0
def test_define_structure():
    args = ["project", "-p", "package", "-d", "description"]
    opts = cli.parse_args(args)
    _, opts = api.get_default_options({}, opts)
    struct, _ = structure.define_structure({}, opts)
    assert isinstance(struct, dict)
Exemplo n.º 46
0
def test_parse_args_with_old_setuptools(old_setuptools_mock):
    args = ["my-project"]
    with pytest.raises(OldSetuptools):
        cli.parse_args(args)
Exemplo n.º 47
0
def test_parse_pretend():
    for flag in ["--pretend", "-P"]:
        opts = cli.parse_args(["my-project", flag])
        assert opts["pretend"]
    opts = cli.parse_args(["my-project"])
    assert not opts["pretend"]
Exemplo n.º 48
0
def test_parse_verbose_option():
    for quiet in ("--verbose", "-v"):
        args = ["my-project", quiet]
        opts = cli.parse_args(args)
        assert opts["log_level"] == logging.INFO
Exemplo n.º 49
0
def test_parse_default_log_level():
    args = ["my-project"]
    opts = cli.parse_args(args)
    assert opts["log_level"] == logging.WARNING
Exemplo n.º 50
0
def test_create_django_project(nodjango_admin_mock):  # noqa
    args = ["project", "-p", "package", "-d", "description"]
    opts = cli.parse_args(args)
    with pytest.raises(RuntimeError):
        structure.create_django_proj(opts)
Exemplo n.º 51
0
def test_parse_args():
    args = ["my-project"]
    opts = cli.parse_args(args)
    assert opts["project"] == "my-project"
Exemplo n.º 52
0
def test_get_default_opts():
    args = ["project", "-p", "package", "-d", "description"]
    opts = cli.parse_args(args)
    new_opts = cli.get_default_opts(opts["project"], **opts)
    assert "author" not in opts
    assert "author" in new_opts
Exemplo n.º 53
0
def test_process_opts_raises():
    opts = cli.parse_args(["non-existent", "--update"])
    with pytest.raises(NoPyScaffoldProject):
        cli.process_opts(opts)
Exemplo n.º 54
0
def test_get_defaults_opts_with_cookiecutter():
    args = ["project", "--with-cookiecutter", "http://..."]
    opts = cli.parse_args(args)
    new_opts = cli.get_default_opts(opts["project"], **opts)
    assert new_opts["force"]
Exemplo n.º 55
0
def test_parse_list_actions():
    opts = cli.parse_args(["my-project", "--list-actions"])
    assert opts["command"] == cli.list_actions
    opts = cli.parse_args(["my-project"])
    assert opts["command"] == cli.run_scaffold