From 12dac1bd597e4b2c92d2f23b622cc85ab9e750a1 Mon Sep 17 00:00:00 2001 From: teald Date: Tue, 29 Oct 2024 11:54:30 -0700 Subject: [PATCH 1/2] test(template): Add test for uppercase instrument names --- tests/test_template.py | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/tests/test_template.py b/tests/test_template.py index 8217265..791afe1 100644 --- a/tests/test_template.py +++ b/tests/test_template.py @@ -6,6 +6,8 @@ from pathlib import Path import re +import pytest + LOGGER = logging.getLogger(__name__) @@ -75,5 +77,32 @@ def test_default_template(cookies, monkeypatch): if path.suffix in [".yml", ".yaml"] and "github" in str(path): continue - assert r"{{" not in line, errstr - assert r"}}" not in line, errstr + assert "{{" not in line, errstr + assert "}}" not in line, errstr + + +@pytest.mark.parametrize( + "extra_context", + [{}, {"instrument_name": "OTHERNAME"}, {"instrument_name": "othername"}], +) +def test_lowercase_package_names(extra_context, cookies, monkeypatch): + """Test that certain dirs follow PEP8 package name guidelines. + + See: https://peps.python.org/pep-0008/#package-and-module-names + """ + result = cookies.bake(extra_context=extra_context) + + monkeypatch.chdir(result.project_path) + + instrument_name = result.context["instrument_name"] + + expected_lowercase_paths = [ + f"{instrument_name}dr/", + f"{instrument_name}_instruments/", + ] + + expected_lowercase_paths = [Path(p.lower()) for p in expected_lowercase_paths] + + for path in expected_lowercase_paths: + assert path.exists() + assert path.is_dir() From 5b77d30b7dc882721fe14b8f497716c2e153b6c1 Mon Sep 17 00:00:00 2001 From: teald Date: Tue, 29 Oct 2024 15:03:17 -0700 Subject: [PATCH 2/2] fix(template): Rename directory to use lowercase instrument name. --- .../__init__.py | 0 .../lookups/BPM/README.md | 0 .../lookups/MDF/README.md | 0 .../lookups/__init__.py | 0 .../lookups/timestamp_keywords.py | 0 .../parameters_{{ cookiecutter.instrument_name }}.py | 0 .../parameters_{{ cookiecutter.instrument_name }}_echelle.py | 0 .../primitives_{{ cookiecutter.instrument_name }}.py | 0 .../primitives_{{ cookiecutter.instrument_name }}_echelle.py | 0 .../recipes/README.md | 0 .../recipes/__init__.py | 0 .../recipes/sq/README.md | 0 .../recipes/sq/__init__.py | 0 .../recipes/sq/recipes_DARK.py | 0 .../recipes/sq/recipes_ECHELLE.py | 0 15 files changed, 0 insertions(+), 0 deletions(-) rename {{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{{ cookiecutter.instrument_name }} => {{ cookiecutter.instrument_name_lower }}}/__init__.py (100%) rename {{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{{ cookiecutter.instrument_name }} => {{ cookiecutter.instrument_name_lower }}}/lookups/BPM/README.md (100%) rename {{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{{ cookiecutter.instrument_name }} => {{ cookiecutter.instrument_name_lower }}}/lookups/MDF/README.md (100%) rename {{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{{ cookiecutter.instrument_name }} => {{ cookiecutter.instrument_name_lower }}}/lookups/__init__.py (100%) rename {{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{{ cookiecutter.instrument_name }} => {{ cookiecutter.instrument_name_lower }}}/lookups/timestamp_keywords.py (100%) rename {{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{{ cookiecutter.instrument_name }} => {{ cookiecutter.instrument_name_lower }}}/parameters_{{ cookiecutter.instrument_name }}.py (100%) rename {{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{{ cookiecutter.instrument_name }} => {{ cookiecutter.instrument_name_lower }}}/parameters_{{ cookiecutter.instrument_name }}_echelle.py (100%) rename {{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{{ cookiecutter.instrument_name }} => {{ cookiecutter.instrument_name_lower }}}/primitives_{{ cookiecutter.instrument_name }}.py (100%) rename {{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{{ cookiecutter.instrument_name }} => {{ cookiecutter.instrument_name_lower }}}/primitives_{{ cookiecutter.instrument_name }}_echelle.py (100%) rename {{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{{ cookiecutter.instrument_name }} => {{ cookiecutter.instrument_name_lower }}}/recipes/README.md (100%) rename {{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{{ cookiecutter.instrument_name }} => {{ cookiecutter.instrument_name_lower }}}/recipes/__init__.py (100%) rename {{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{{ cookiecutter.instrument_name }} => {{ cookiecutter.instrument_name_lower }}}/recipes/sq/README.md (100%) rename {{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{{ cookiecutter.instrument_name }} => {{ cookiecutter.instrument_name_lower }}}/recipes/sq/__init__.py (100%) rename {{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{{ cookiecutter.instrument_name }} => {{ cookiecutter.instrument_name_lower }}}/recipes/sq/recipes_DARK.py (100%) rename {{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{{ cookiecutter.instrument_name }} => {{ cookiecutter.instrument_name_lower }}}/recipes/sq/recipes_ECHELLE.py (100%) diff --git a/{{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name }}/__init__.py b/{{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name_lower }}/__init__.py similarity index 100% rename from {{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name }}/__init__.py rename to {{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name_lower }}/__init__.py diff --git a/{{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name }}/lookups/BPM/README.md b/{{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name_lower }}/lookups/BPM/README.md similarity index 100% rename from {{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name }}/lookups/BPM/README.md rename to {{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name_lower }}/lookups/BPM/README.md diff --git a/{{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name }}/lookups/MDF/README.md b/{{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name_lower }}/lookups/MDF/README.md similarity index 100% rename from {{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name }}/lookups/MDF/README.md rename to {{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name_lower }}/lookups/MDF/README.md diff --git a/{{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name }}/lookups/__init__.py b/{{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name_lower }}/lookups/__init__.py similarity index 100% rename from {{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name }}/lookups/__init__.py rename to {{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name_lower }}/lookups/__init__.py diff --git a/{{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name }}/lookups/timestamp_keywords.py b/{{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name_lower }}/lookups/timestamp_keywords.py similarity index 100% rename from {{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name }}/lookups/timestamp_keywords.py rename to {{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name_lower }}/lookups/timestamp_keywords.py diff --git a/{{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name }}/parameters_{{ cookiecutter.instrument_name }}.py b/{{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name_lower }}/parameters_{{ cookiecutter.instrument_name }}.py similarity index 100% rename from {{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name }}/parameters_{{ cookiecutter.instrument_name }}.py rename to {{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name_lower }}/parameters_{{ cookiecutter.instrument_name }}.py diff --git a/{{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name }}/parameters_{{ cookiecutter.instrument_name }}_echelle.py b/{{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name_lower }}/parameters_{{ cookiecutter.instrument_name }}_echelle.py similarity index 100% rename from {{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name }}/parameters_{{ cookiecutter.instrument_name }}_echelle.py rename to {{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name_lower }}/parameters_{{ cookiecutter.instrument_name }}_echelle.py diff --git a/{{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name }}/primitives_{{ cookiecutter.instrument_name }}.py b/{{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name_lower }}/primitives_{{ cookiecutter.instrument_name }}.py similarity index 100% rename from {{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name }}/primitives_{{ cookiecutter.instrument_name }}.py rename to {{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name_lower }}/primitives_{{ cookiecutter.instrument_name }}.py diff --git a/{{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name }}/primitives_{{ cookiecutter.instrument_name }}_echelle.py b/{{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name_lower }}/primitives_{{ cookiecutter.instrument_name }}_echelle.py similarity index 100% rename from {{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name }}/primitives_{{ cookiecutter.instrument_name }}_echelle.py rename to {{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name_lower }}/primitives_{{ cookiecutter.instrument_name }}_echelle.py diff --git a/{{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name }}/recipes/README.md b/{{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name_lower }}/recipes/README.md similarity index 100% rename from {{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name }}/recipes/README.md rename to {{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name_lower }}/recipes/README.md diff --git a/{{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name }}/recipes/__init__.py b/{{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name_lower }}/recipes/__init__.py similarity index 100% rename from {{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name }}/recipes/__init__.py rename to {{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name_lower }}/recipes/__init__.py diff --git a/{{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name }}/recipes/sq/README.md b/{{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name_lower }}/recipes/sq/README.md similarity index 100% rename from {{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name }}/recipes/sq/README.md rename to {{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name_lower }}/recipes/sq/README.md diff --git a/{{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name }}/recipes/sq/__init__.py b/{{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name_lower }}/recipes/sq/__init__.py similarity index 100% rename from {{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name }}/recipes/sq/__init__.py rename to {{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name_lower }}/recipes/sq/__init__.py diff --git a/{{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name }}/recipes/sq/recipes_DARK.py b/{{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name_lower }}/recipes/sq/recipes_DARK.py similarity index 100% rename from {{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name }}/recipes/sq/recipes_DARK.py rename to {{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name_lower }}/recipes/sq/recipes_DARK.py diff --git a/{{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name }}/recipes/sq/recipes_ECHELLE.py b/{{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name_lower }}/recipes/sq/recipes_ECHELLE.py similarity index 100% rename from {{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name }}/recipes/sq/recipes_ECHELLE.py rename to {{ cookiecutter.project_slug }}/{{ cookiecutter.instrument_name_lower }}dr/{{ cookiecutter.instrument_name_lower }}/recipes/sq/recipes_ECHELLE.py