2424def get_config () -> dict :
2525 """Generate all the config keys"""
2626 config_file = Path ("./cookiecutter.json" )
27- with open (config_file ) as file_object :
28- config = json .load (file_object )
27+ with config_file . open (encoding = "utf-8" ) as f :
28+ config = json .load (f )
2929 return config
3030
3131
@@ -227,6 +227,19 @@ def test_default_project(cookies):
227227 if repo .is_dirty (untracked_files = True ):
228228 pytest .fail ("Something went wrong with the project's post-generation hook" )
229229
230+ # Extract project_name and project_slug from cookiecutter.json
231+ config_file = Path ("./cookiecutter.json" )
232+ with config_file .open (encoding = "utf-8" ) as f :
233+ generated_config = json .load (f )
234+ github_org = generated_config .get ("github_org" )
235+ project_name = generated_config .get ("project_name" )
236+ project_name_lower = project_name .lower ()
237+
238+ # Keep this logic aligned with the template's README.md
239+ # It's important that this has -s in the name to test the docker hub image name sanitization
240+ default_image_name = f"{ github_org } /{ project_name_lower } "
241+ default_image_name_and_tag = f"{ default_image_name } :latest"
242+
230243 try :
231244 env = os .environ .copy ()
232245 env .pop ("VIRTUAL_ENV" , None ) # Clean VIRTUAL_ENV to avoid conflicts
@@ -273,11 +286,9 @@ def test_default_project(cookies):
273286 env = env ,
274287 )
275288
276- default_image = "zenable-io/todo:latest"
277-
278289 # Ensure that --help exits 0
279290 subprocess .run (
280- ["docker" , "run" , "--rm" , default_image , "--help" ],
291+ ["docker" , "run" , "--rm" , default_image_name_and_tag , "--help" ],
281292 capture_output = True ,
282293 check = True ,
283294 cwd = project ,
@@ -288,7 +299,7 @@ def test_default_project(cookies):
288299 "docker" ,
289300 "run" ,
290301 "--rm" ,
291- default_image ,
302+ default_image_name_and_tag ,
292303 "--debug" ,
293304 "--verbose" ,
294305 ]
0 commit comments