@@ -211,6 +211,53 @@ def test_autofix_hook(cookies, context):
211211 pytest .fail (f"stdout: { error .stdout .decode ('utf-8' )} , stderr: { error .stderr .decode ('utf-8' )} " )
212212
213213
214+ @pytest .mark .unit
215+ @pytest .mark .parametrize (
216+ "invalid_name" ,
217+ [
218+ "123invalid" , # starts with number
219+ "_invalid" , # starts with underscore
220+ "-invalid" , # starts with dash
221+ "9project" , # starts with number
222+ "!invalid" , # starts with special character
223+ ],
224+ )
225+ def test_invalid_project_name_validation (cookies , invalid_name ):
226+ """
227+ Test that project names starting with non-alphabetical characters are rejected
228+ """
229+ result = cookies .bake (extra_context = {"project_name" : invalid_name })
230+
231+ # The generation should fail due to validation
232+ assert result .exit_code != 0 , f"Expected validation failure for project name: { invalid_name } "
233+
234+
235+ @pytest .mark .unit
236+ @pytest .mark .parametrize (
237+ "valid_name" ,
238+ [
239+ "ValidProject" , # starts with uppercase
240+ "validproject" , # starts with lowercase
241+ "My Project" , # starts with uppercase, has space
242+ "a1234" , # starts with lowercase, has numbers
243+ "Z_project" , # starts with uppercase, has underscore
244+ ],
245+ )
246+ def test_valid_project_name_validation (cookies , valid_name ):
247+ """
248+ Test that valid project names starting with alphabetical characters are accepted
249+ """
250+ # Turn off the post generation hooks for faster testing
251+ os .environ ["RUN_POST_HOOK" ] = "false"
252+
253+ result = cookies .bake (extra_context = {"project_name" : valid_name })
254+
255+ # The generation should succeed
256+ assert result .exit_code == 0 , f"Expected validation success for project name: { valid_name } "
257+ assert result .exception is None
258+ assert result .project_path .is_dir ()
259+
260+
214261@pytest .mark .integration
215262@pytest .mark .slow
216263def test_default_project (cookies ):
0 commit comments