Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove long package name handling #51

Merged
merged 5 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions tests/test_cookiecutter_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

from pytest_cookies.plugin import Cookies, Result

LONG_PACKAGE_NAME = "hyperextralongpackagenametomessupimportformatting"


@pytest.fixture(scope="session")
def session_context():
Expand All @@ -38,12 +36,12 @@ def context(session_context: dict[str, str]):


SUPPORTED_COMBINATIONS = [
{},
{"plugin_package": LONG_PACKAGE_NAME},
{}, # test with default values
{"ci_provider": "None"},
{"add_vscode_config": True},
{"include_processing": True},
{"use_qgis_plugin_tools": True},
{"use_qgis_plugin_tools": True, "include_processing": True},
{"use_qgis_plugin_tools": True, "include_processing": False},
{"license": "GPL3"},
]

Expand All @@ -70,7 +68,7 @@ def baked_project(
if isinstance(baked_project.exception, UndefinedVariableInTemplate):
print(baked_project.exception.message) # noqa: T201
print(f"Error message: {baked_project.exception.error.message}") # noqa: T201
sys.exit(1)
pytest.fail("Undefined variable in template")

return baked_project

Expand Down Expand Up @@ -103,18 +101,12 @@ def run_cli_command(args: list[str], cwd: str):
def test_ruff_linting_passes(baked_project: Result):
"""Generated project should pass ruff check."""

if baked_project.context["plugin_package"] == LONG_PACKAGE_NAME:
pytest.xfail(reason="long package names makes imports to be reformatted. TODO: fix")

run_cli_command([sys.executable, "-m", "ruff", "check", "."], cwd=str(baked_project.project_path))


def test_ruff_formatting_passes(baked_project: Result):
"""Generated project should pass ruff formatting."""

if baked_project.context["plugin_package"] == LONG_PACKAGE_NAME:
pytest.xfail(reason="long package names makes imports to be reformatted. TODO: fix")

run_cli_command([sys.executable, "-m", "ruff", "format", "--check", "."], cwd=str(baked_project.project_path))


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,9 @@ from qgis.PyQt.QtWidgets import QAction, QWidget
from qgis.utils import iface

{% if cookiecutter.include_processing -%}
from {{cookiecutter.plugin_package}}.{{cookiecutter.plugin_package}}_processing.provider import Provider
{% endif -%}
{% if cookiecutter.plugin_package|length < 7 -%}
from {{cookiecutter.plugin_package}}.qgis_plugin_tools.tools.custom_logging import setup_logger, teardown_logger
{% else -%}
from {{cookiecutter.plugin_package}}.qgis_plugin_tools.tools.custom_logging import (
setup_logger,
teardown_logger,
)
{% endif -%}
from {{cookiecutter.plugin_package}}.qgis_plugin_tools.tools.i18n import setup_translation
from {{cookiecutter.plugin_package}}.qgis_plugin_tools.tools.resources import plugin_name

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from qgis.core import QgsProcessingProvider

from {{cookiecutter.plugin_package}}.{{cookiecutter.plugin_package}}_processing.processing_algorithm import ProcessingAlgorithm # type: ignore[import-not-found]
from {{cookiecutter.plugin_package}}.{{cookiecutter.plugin_package}}_processing.processing_algorithm import ProcessingAlgorithm


class Provider(QgsProcessingProvider):
Expand Down
Loading