@@ -124,3 +124,62 @@ def test_litestar_generator_docker_compose_rendering(tmp_path: Path) -> None:
124124 # Check services
125125 assert "image: postgres:17.7-alpine3.23" in content
126126 assert "image: redis:8.4.0-bookworm" in content
127+
128+
129+ def test_litestar_generator_saq_context (tmp_path : Path ) -> None :
130+ """Verify Litestar generator template context values with SAQ plugin enabled."""
131+ config = ProjectConfig (
132+ name = "SAQ Test" ,
133+ framework = Framework .LITESTAR ,
134+ database = Database .NONE ,
135+ memory_store = MemoryStore .REDIS ,
136+ plugins = ["litestar_saq" ],
137+ docker = False ,
138+ docker_infra = False ,
139+ )
140+
141+ generator = LitestarGenerator (config , tmp_path )
142+ context = generator ._get_template_context ()
143+
144+ assert context ["litestar_saq" ] is True
145+ assert context ["has_store" ] is True
146+ assert context ["memory_store" ] == MemoryStore .REDIS
147+
148+
149+ def test_litestar_generator_saq_rendering (tmp_path : Path ) -> None :
150+ """Verify that SAQ plugin templates are correctly rendered into the output directory."""
151+ config = ProjectConfig (
152+ name = "SAQ Plugin Test" ,
153+ framework = Framework .LITESTAR ,
154+ database = Database .NONE ,
155+ memory_store = MemoryStore .REDIS ,
156+ plugins = ["litestar_saq" ],
157+ docker = False ,
158+ docker_infra = False ,
159+ )
160+
161+ generator = LitestarGenerator (config , tmp_path )
162+ generator .generate ()
163+
164+ # Verify base files
165+ assert (tmp_path / "pyproject.toml" ).exists ()
166+ assert (tmp_path / "src" / "backend" / "app.py" ).exists ()
167+ assert (tmp_path / "src" / "backend" / "config.py" ).exists ()
168+
169+ # Verify SAQ plugin files
170+ assert (tmp_path / "src" / "backend" / "lib" / "tasks.py" ).exists ()
171+
172+ # Verify SAQ config in config.py
173+ config_content = (tmp_path / "src" / "backend" / "config.py" ).read_text ()
174+ assert "from litestar_saq import QueueConfig, SAQConfig, SAQPlugin" in config_content
175+ assert "saq = SAQPlugin(" in config_content
176+ assert 'QueueConfig(name="default"' in config_content
177+
178+ # Verify SAQ plugin in app.py
179+ app_content = (tmp_path / "src" / "backend" / "app.py" ).read_text ()
180+ assert "from .config import saq" in app_content
181+ assert "saq," in app_content
182+
183+ # Verify SAQ dependency in pyproject.toml
184+ pyproject_content = (tmp_path / "pyproject.toml" ).read_text ()
185+ assert "litestar-saq>=0.7.0" in pyproject_content
0 commit comments