Skip to content

Commit 4e2c6bd

Browse files
authored
♻️ Refactor logic to allow running pytest tests locally (#683)
1 parent 64e21bb commit 4e2c6bd

3 files changed

Lines changed: 12 additions & 3 deletions

File tree

backend/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ Modify or add SQLModel models for data and SQL tables in `./backend/app/models.p
6767

6868
Add and modify tasks to the Celery worker in `./backend/app/worker.py`.
6969

70+
### VS Code
71+
72+
There are already configurations in place to run the backend through the VS Code debugger, so that you can use breakpoints, pause and explore variables, etc.
73+
74+
The setup is also already configured so you can run the tests through the VS Code Python tests tab.
75+
7076
### Docker Compose Override
7177

7278
During development, you can change Docker Compose settings that will only affect the local development environment in the file `docker-compose.override.yml`.

backend/app/core/config.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ def parse_cors(v: Any) -> list[str] | str:
2323

2424

2525
class Settings(BaseSettings):
26-
model_config = SettingsConfigDict(env_file=".env", env_ignore_empty=True)
26+
model_config = SettingsConfigDict(
27+
env_file=".env", env_ignore_empty=True, extra="ignore"
28+
)
2729
API_V1_STR: str = "/api/v1"
2830
SECRET_KEY: str = secrets.token_urlsafe(32)
2931
# 60 minutes * 24 hours * 8 days = 8 days
@@ -77,7 +79,6 @@ def set_default_emails_from(self) -> Self:
7779
return self
7880

7981
EMAIL_RESET_TOKEN_EXPIRE_HOURS: int = 48
80-
EMAIL_TEMPLATES_DIR: str = "/app/app/email-templates/build"
8182

8283
@computed_field # type: ignore[misc]
8384
@property

backend/app/utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ class EmailData:
1818

1919

2020
def render_email_template(*, template_name: str, context: dict[str, Any]) -> str:
21-
template_str = (Path(settings.EMAIL_TEMPLATES_DIR) / template_name).read_text()
21+
template_str = (
22+
Path(__file__).parent / "email-templates" / "build" / template_name
23+
).read_text()
2224
html_content = Template(template_str).render(context)
2325
return html_content
2426

0 commit comments

Comments
 (0)