Skip to content

Commit

Permalink
changed project name to project slug in module imports
Browse files Browse the repository at this point in the history
  • Loading branch information
santacodes committed Jul 24, 2024
1 parent 8bc8a67 commit d6fd552
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cookiecutter.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"project_name": "pybamm_example_project",
"project_name": "pybamm-example-project",
"platform": [
"github",
"gitlab"
Expand Down
2 changes: 1 addition & 1 deletion tests/template_tests/test_project_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_bake_project(cookies: Cookies):
result = cookies.bake()
assert result.exit_code == 0, f"Exited with code {result.exit_code}, expected 0"
assert result.exception is None, result.exception
assert result.project_path.name == "pybamm_example_project"
assert result.project_path.name == "pybamm-example-project"
assert result.project_path.is_dir(), f"Project directory {result.project_path} not found"


Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
import {{ cookiecutter.project_name }}
import {{ cookiecutter.__project_slug }}
import importlib.util
import sys
from pathlib import Path
Expand All @@ -8,8 +8,8 @@
def test_parameter_sets_entry_points():
"""Test if the parameter_sets via entry points are loaded correctly."""

entry_points = list({{ cookiecutter.project_name }}.parameter_sets)
parameter_sets = Path("src/{{ cookiecutter.project_name }}/parameters/input/").glob("*.py")
entry_points = list({{ cookiecutter.__project_slug }}.parameter_sets)
parameter_sets = Path("src/{{ cookiecutter.__project_slug }}/parameters/input/").glob("*.py")
# Making a list of parameter sets in the parameters/input directory
parameter_sets = [x.stem for x in parameter_sets]

Expand All @@ -19,9 +19,9 @@ def test_parameter_sets_entry_points():
def test_parameter_sets_entry_point_load():
"""Testing if the values get loaded via parameter entry points and are equal when loaded through entry points"""
# Loading parameter_sets through entry points
parameters = {{ cookiecutter.project_name }}.parameter_sets['Chen2020']
parameters = {{ cookiecutter.__project_slug }}.parameter_sets['Chen2020']
# Loading parameter sets through the source file by dynamically loading Chen2020.py as a module
spec = importlib.util.spec_from_file_location("Chen2020mod", "src/{{ cookiecutter.project_name }}/parameters/input/Chen2020.py")
spec = importlib.util.spec_from_file_location("Chen2020mod", "src/{{ cookiecutter.__project_slug }}/parameters/input/Chen2020.py")
chen_module = importlib.util.module_from_spec(spec)
sys.modules["Chen2020mod"] = chen_module
spec.loader.exec_module(chen_module)
Expand All @@ -31,8 +31,8 @@ def test_parameter_sets_entry_point_load():
def test_model_entry_points():
"""Test if the models via entry points are loaded correctly."""

entry_points = list({{ cookiecutter.project_name }}.models)
models = Path("src/{{ cookiecutter.project_name }}/models/input/").glob("*.py")
entry_points = list({{ cookiecutter.__project_slug }}.models)
models = Path("src/{{ cookiecutter.__project_slug }}/models/input/").glob("*.py")
# Making a list Parameter sets in the parameters/input directory
models = [x.stem for x in models]

Expand All @@ -41,5 +41,5 @@ def test_model_entry_points():
def test_model_entry_point_load():
"""Testing if the model gets initialised and returned."""
# Loading parameter_sets through entry points
model_instance = {{ cookiecutter.project_name }}.Model("SPM")
model_instance = {{ cookiecutter.__project_slug }}.Model("SPM")
assert model_instance is not None

0 comments on commit d6fd552

Please sign in to comment.