Skip to content

Commit 8ca274a

Browse files
committed
Back to medical_records
1 parent 4b532c3 commit 8ca274a

3 files changed

Lines changed: 10 additions & 66 deletions

File tree

src/dbx_python_cli/commands/project.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ def add_project(
514514
if add_qe:
515515
typer.echo(f"🔐 Enabling Queryable Encryption for project '{name}'...")
516516
try:
517-
_enable_qe(project_path, name, wagtail=add_wagtail)
517+
_enable_qe(project_path, name)
518518
except Exception as e:
519519
typer.echo(
520520
f"⚠️ Project created successfully, but QE setup failed: {e}",
@@ -956,8 +956,8 @@ def _enable_wagtail(project_path: Path, project_name: str) -> None:
956956
f.write(wagtail_block)
957957

958958

959-
def _enable_qe(project_path: Path, project_name: str, wagtail: bool = False) -> None:
960-
"""Uncomment the QE block in settings and select the correct medical_records app."""
959+
def _enable_qe(project_path: Path, project_name: str) -> None:
960+
"""Uncomment the QE block in settings."""
961961
settings_file = project_path / project_name / "settings" / f"{project_name}.py"
962962
if settings_file.exists():
963963
content = settings_file.read_text()
@@ -969,16 +969,6 @@ def _enable_qe(project_path: Path, project_name: str, wagtail: bool = False) ->
969969
)
970970
settings_file.write_text(content)
971971

972-
if wagtail:
973-
qe_settings_file = project_path / project_name / "settings" / "qe.py"
974-
if qe_settings_file.exists():
975-
qe_content = qe_settings_file.read_text()
976-
qe_content = qe_content.replace(
977-
'"medical_records.medical_records_django"',
978-
'"medical_records.medical_records_wagtail"',
979-
)
980-
qe_settings_file.write_text(qe_content)
981-
982972

983973
def _setup_wagtail_initial_data(
984974
python_path: str,

src/dbx_python_cli/templates/project_template/project_name/settings/qe.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from pymongo.encryption_options import AutoEncryptionOpts
44

55
QE_INSTALLED_APPS = [
6-
"medical_records.medical_records_django",
6+
"medical_records",
77
]
88

99
DATABASES = {

tests/test_project_command.py

Lines changed: 6 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -502,9 +502,7 @@ def test_enable_qe_activates_settings(tmp_path):
502502
"# from .qe import * # noqa\n"
503503
"# INSTALLED_APPS += QE_INSTALLED_APPS # noqa: F405\n"
504504
)
505-
(settings_dir / "qe.py").write_text(
506-
'QE_INSTALLED_APPS = ["medical_records.medical_records_django"]\n'
507-
)
505+
(settings_dir / "qe.py").write_text('QE_INSTALLED_APPS = ["medical_records"]\n')
508506

509507
_enable_qe(tmp_path, "myproject")
510508

@@ -514,48 +512,6 @@ def test_enable_qe_activates_settings(tmp_path):
514512
assert "INSTALLED_APPS += QE_INSTALLED_APPS # noqa: F405" in content
515513

516514

517-
def test_enable_qe_uses_django_app_by_default(tmp_path):
518-
"""Test that _enable_qe leaves medical_records.medical_records_django when wagtail=False."""
519-
from dbx_python_cli.commands.project import _enable_qe
520-
521-
settings_dir = tmp_path / "myproject" / "settings"
522-
settings_dir.mkdir(parents=True)
523-
(settings_dir / "myproject.py").write_text(
524-
"# from .qe import * # noqa\n"
525-
"# INSTALLED_APPS += QE_INSTALLED_APPS # noqa: F405\n"
526-
)
527-
qe_file = settings_dir / "qe.py"
528-
qe_file.write_text(
529-
'QE_INSTALLED_APPS = ["medical_records.medical_records_django"]\n'
530-
)
531-
532-
_enable_qe(tmp_path, "myproject", wagtail=False)
533-
534-
assert '"medical_records.medical_records_django"' in qe_file.read_text()
535-
536-
537-
def test_enable_qe_uses_wagtail_app_when_stacked(tmp_path):
538-
"""Test that _enable_qe replaces app with medical_records.medical_records_wagtail when wagtail=True."""
539-
from dbx_python_cli.commands.project import _enable_qe
540-
541-
settings_dir = tmp_path / "myproject" / "settings"
542-
settings_dir.mkdir(parents=True)
543-
(settings_dir / "myproject.py").write_text(
544-
"# from .qe import * # noqa\n"
545-
"# INSTALLED_APPS += QE_INSTALLED_APPS # noqa: F405\n"
546-
)
547-
qe_file = settings_dir / "qe.py"
548-
qe_file.write_text(
549-
'QE_INSTALLED_APPS = ["medical_records.medical_records_django"]\n'
550-
)
551-
552-
_enable_qe(tmp_path, "myproject", wagtail=True)
553-
554-
qe_content = qe_file.read_text()
555-
assert '"medical_records.medical_records_wagtail"' in qe_content
556-
assert '"medical_records.medical_records_django"' not in qe_content
557-
558-
559515
def test_create_pyproject_toml_includes_pymongocrypt_when_qe(tmp_path):
560516
"""Test that _create_pyproject_toml adds pymongocrypt to dependencies when qe=True."""
561517
from dbx_python_cli.commands.project import _create_pyproject_toml
@@ -582,11 +538,11 @@ def test_create_pyproject_toml_excludes_pymongocrypt_by_default(tmp_path):
582538
assert '"pymongocrypt"' not in deps_section
583539

584540

585-
def test_qe_with_medical_records_adds_django_app_to_installed_apps(tmp_path):
586-
"""When --qe and --with medical-records are both used, medical_records.medical_records_django must be in INSTALLED_APPS.
541+
def test_qe_with_medical_records_adds_app_to_installed_apps(tmp_path):
542+
"""When --qe and --with medical-records are both used, medical_records must be in INSTALLED_APPS.
587543
588544
_enable_qe uncomments the QE import block in the project settings, which adds
589-
QE_INSTALLED_APPS (containing medical_records.medical_records_django) to INSTALLED_APPS.
545+
QE_INSTALLED_APPS (containing medical_records) to INSTALLED_APPS.
590546
"""
591547
from dbx_python_cli.commands.project import _enable_qe
592548

@@ -598,13 +554,11 @@ def test_qe_with_medical_records_adds_django_app_to_installed_apps(tmp_path):
598554
"# INSTALLED_APPS += QE_INSTALLED_APPS # noqa: F405\n"
599555
)
600556
qe_file = settings_dir / "qe.py"
601-
qe_file.write_text(
602-
'QE_INSTALLED_APPS = ["medical_records.medical_records_django"]\n'
603-
)
557+
qe_file.write_text('QE_INSTALLED_APPS = ["medical_records"]\n')
604558

605559
_enable_qe(tmp_path, "myproject")
606560

607561
settings_content = settings_file.read_text()
608562
assert "from .qe import * # noqa" in settings_content
609563
assert "INSTALLED_APPS += QE_INSTALLED_APPS # noqa: F405" in settings_content
610-
assert '"medical_records.medical_records_django"' in qe_file.read_text()
564+
assert '"medical_records"' in qe_file.read_text()

0 commit comments

Comments
 (0)