Skip to content

Commit

Permalink
test: don't add existing style again
Browse files Browse the repository at this point in the history
  • Loading branch information
andreoliwa committed Nov 19, 2023
1 parent 41a6393 commit dc9bc65
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 25 deletions.
10 changes: 5 additions & 5 deletions docs/requirements.txt
@@ -1,10 +1,10 @@
alabaster==0.7.13 ; python_version >= "3.8" and python_version < "4.0"
attrs==23.1.0 ; python_version >= "3.8" and python_version < "4.0"
autorepr==0.3.0 ; python_version >= "3.8" and python_version < "4.0"
babel==2.13.1 ; python_version >= "3.8" and python_version < "4.0"
babel==2.13.0 ; python_version >= "3.8" and python_version < "4.0"
cattrs==23.1.2 ; python_version >= "3.8" and python_version < "4.0"
certifi==2023.7.22 ; python_version >= "3.8" and python_version < "4.0"
charset-normalizer==3.3.2 ; python_version >= "3.8" and python_version < "4.0"
charset-normalizer==3.3.0 ; python_version >= "3.8" and python_version < "4.0"
click==8.1.7 ; python_version >= "3.8" and python_version < "4.0"
colorama==0.4.6 ; python_version >= "3.8" and python_version < "4.0" and (platform_system == "Windows" or sys_platform == "win32")
configupdater==3.1.1 ; python_version >= "3.8" and python_version < "4.0"
Expand All @@ -16,7 +16,7 @@ flake8==5.0.4 ; python_version >= "3.8" and python_version < "4.0"
flatten-dict==0.4.2 ; python_version >= "3.8" and python_version < "4.0"
furl==2.1.3 ; python_version >= "3.8" and python_version < "4.0"
gitignore-parser==0.1.9 ; python_version >= "3.8" and python_version < "4.0"
identify==2.5.31 ; python_version >= "3.8" and python_version < "4.0"
identify==2.5.30 ; python_version >= "3.8" and python_version < "4.0"
idna==3.4 ; python_version >= "3.8" and python_version < "4.0"
imagesize==1.4.1 ; python_version >= "3.8" and python_version < "4.0"
importlib-metadata==6.8.0 ; python_version >= "3.8" and python_version < "3.10"
Expand All @@ -25,7 +25,7 @@ iniconfig==2.0.0 ; python_version >= "3.8" and python_version < "4.0"
jinja2==3.1.2 ; python_version >= "3.8" and python_version < "4.0"
jmespath==1.0.1 ; python_version >= "3.8" and python_version < "4.0"
jsonschema-specifications==2023.7.1 ; python_version >= "3.8" and python_version < "4.0"
jsonschema==4.19.2 ; python_version >= "3.8" and python_version < "4.0"
jsonschema==4.19.1 ; python_version >= "3.8" and python_version < "4.0"
loguru==0.7.2 ; python_version >= "3.8" and python_version < "4.0"
markupsafe==2.1.3 ; python_version >= "3.8" and python_version < "4.0"
marshmallow-polyfield==5.11 ; python_version >= "3.8" and python_version < "4.0"
Expand All @@ -41,7 +41,7 @@ pycodestyle==2.9.1 ; python_version >= "3.8" and python_version < "4.0"
pyflakes==2.5.0 ; python_version >= "3.8" and python_version < "4.0"
pygments==2.16.1 ; python_version >= "3.8" and python_version < "4.0"
pytest-socket==0.6.0 ; python_version >= "3.8" and python_version < "4.0"
pytest==7.4.3 ; python_version >= "3.8" and python_version < "4.0"
pytest==7.4.2 ; python_version >= "3.8" and python_version < "4.0"
python-slugify==8.0.1 ; python_version >= "3.8" and python_version < "4.0"
pytz==2023.3.post1 ; python_version >= "3.8" and python_version < "3.9"
referencing==0.30.2 ; python_version >= "3.8" and python_version < "4.0"
Expand Down
41 changes: 21 additions & 20 deletions tests/test_cli.py
Expand Up @@ -53,26 +53,6 @@ def test_missing_style_and_suggest_option(tmp_path: Path) -> None:
)


@pytest.mark.parametrize("config_file", [DOT_NITPICK_TOML, PYTHON_PYPROJECT_TOML])
@pytest.mark.skip(reason="WIP") # TODO(AA): test: remove the skip
def test_config_file_already_has_tool_nitpick_section(tmp_path: Path, config_file: str) -> None:
"""Test if both config files already exist."""
project = ProjectMock(tmp_path, pyproject_toml=False, setup_py=True).save_file(
config_file,
f"""
[{CONFIG_TOOL_NITPICK_KEY}]
style = ['/this/should/not/be/validated-yet.toml']
""",
)
project.cli_init(
[
f"The config file {config_file!r} already has a [{CONFIG_TOOL_NITPICK_KEY}] section.",
"style = ['/this/should/not/be/validated-yet.toml']",
],
exit_code=1,
)


@pytest.fixture()
def style_dir_with_types(shared_datadir: Path) -> Generator[Path, None, None]:
"""A mocked directory with style files organised into "identify" subdirs."""
Expand Down Expand Up @@ -175,4 +155,25 @@ def test_create_the_ignored_styles_array_only_when_suggesting_styles(tmp_path: P
assert not (tmp_path / DOT_NITPICK_TOML).exists()


@pytest.mark.parametrize("fix", [True, False])
def test_dont_add_existing_style_again(tmp_path: Path, fix: bool) -> None:
"""Don't add existing style again."""
unchanged = f"""
[{CONFIG_TOOL_NITPICK_KEY}]
style = ["my-style.toml"]
"""
project = ProjectMock(tmp_path)
project.pyproject_toml(unchanged)
project.cli_init(
f"All done! {EmojiEnum.STAR_CAKE.value} [{CONFIG_TOOL_NITPICK_KEY}]"
f" table left unchanged in '{PYTHON_PYPROJECT_TOML}'",
fix=fix,
style_urls=["my-style.toml"],
exit_code=0,
).assert_file_contents(
PYTHON_PYPROJECT_TOML,
unchanged,
)


# TODO(AA): test: style from CLI should be the first, before the suggested

0 comments on commit dc9bc65

Please sign in to comment.