@@ -318,7 +318,7 @@ def test_asks_for_app_name_after_team(
318318def test_creates_app_on_backend (
319319 logged_in_cli : None , tmp_path : Path , respx_mock : respx .MockRouter
320320) -> None :
321- steps = [Keys .ENTER , Keys .ENTER , * "demo" , Keys .ENTER , Keys .ENTER ]
321+ steps = [Keys .ENTER , Keys .ENTER , * "demo" , Keys .ENTER , Keys .ENTER , Keys . ENTER ]
322322
323323 team = _get_random_team ()
324324
@@ -329,7 +329,7 @@ def test_creates_app_on_backend(
329329 )
330330 )
331331
332- respx_mock .post ("/apps/" , json = {"name" : "demo" , "team_id" : team ["id" ]}).mock (
332+ respx_mock .post ("/apps/" , json = {"name" : "demo" , "team_id" : team ["id" ], "directory" : None }).mock (
333333 return_value = Response (201 , json = _get_random_app (team_id = team ["id" ]))
334334 )
335335
@@ -346,6 +346,39 @@ def test_creates_app_on_backend(
346346 assert "App created successfully" in result .output
347347
348348
349+ @pytest .mark .respx
350+ def test_creates_app_with_directory (
351+ logged_in_cli : None , tmp_path : Path , respx_mock : respx .MockRouter
352+ ) -> None :
353+ steps = [Keys .ENTER , Keys .ENTER , * "demo" , Keys .ENTER , * "src" , Keys .ENTER , Keys .ENTER ]
354+
355+ team = _get_random_team ()
356+
357+ respx_mock .get ("/teams/" ).mock (
358+ return_value = Response (
359+ 200 ,
360+ json = {"data" : [team ]},
361+ )
362+ )
363+
364+ respx_mock .post ("/apps/" , json = {"name" : "demo" , "team_id" : team ["id" ], "directory" : "src" }).mock (
365+ return_value = Response (201 , json = _get_random_app (team_id = team ["id" ]))
366+ )
367+
368+ with (
369+ changing_dir (tmp_path ),
370+ patch ("rich_toolkit.container.getchar" ) as mock_getchar ,
371+ ):
372+ mock_getchar .side_effect = steps
373+
374+ result = runner .invoke (app , ["deploy" ])
375+
376+ assert result .exit_code == 1
377+
378+ assert "App created successfully" in result .output
379+ assert "Directory: src" in result .output
380+
381+
349382@pytest .mark .respx
350383def test_cancels_deployment_when_user_selects_no (
351384 logged_in_cli : None , tmp_path : Path , respx_mock : respx .MockRouter
@@ -355,6 +388,7 @@ def test_cancels_deployment_when_user_selects_no(
355388 Keys .ENTER ,
356389 * "demo" ,
357390 Keys .ENTER ,
391+ Keys .ENTER ,
358392 Keys .DOWN_ARROW ,
359393 Keys .ENTER ,
360394 ]
@@ -420,6 +454,7 @@ def test_exits_successfully_when_deployment_is_done(
420454 * "demo" ,
421455 Keys .ENTER ,
422456 Keys .ENTER ,
457+ Keys .ENTER ,
423458 ]
424459
425460 team_data = _get_random_team ()
@@ -429,7 +464,7 @@ def test_exits_successfully_when_deployment_is_done(
429464 return_value = Response (200 , json = {"data" : [team_data ]})
430465 )
431466
432- respx_mock .post ("/apps/" , json = {"name" : "demo" , "team_id" : team_data ["id" ]}).mock (
467+ respx_mock .post ("/apps/" , json = {"name" : "demo" , "team_id" : team_data ["id" ], "directory" : None }).mock (
433468 return_value = Response (201 , json = app_data )
434469 )
435470
@@ -671,6 +706,7 @@ def _deploy_without_waiting(respx_mock: respx.MockRouter, tmp_path: Path) -> Res
671706 * "demo" ,
672707 Keys .ENTER ,
673708 Keys .ENTER ,
709+ Keys .ENTER ,
674710 ]
675711
676712 team_data = _get_random_team ()
@@ -684,7 +720,7 @@ def _deploy_without_waiting(respx_mock: respx.MockRouter, tmp_path: Path) -> Res
684720 )
685721 )
686722
687- respx_mock .post ("/apps/" , json = {"name" : "demo" , "team_id" : team_data ["id" ]}).mock (
723+ respx_mock .post ("/apps/" , json = {"name" : "demo" , "team_id" : team_data ["id" ], "directory" : None }).mock (
688724 return_value = Response (201 , json = app_data )
689725 )
690726
0 commit comments