@@ -332,7 +332,7 @@ def test_asks_for_app_name_after_team(
332332def test_creates_app_on_backend (
333333 logged_in_cli : None , tmp_path : Path , respx_mock : respx .MockRouter
334334) -> None :
335- steps = [Keys .ENTER , Keys .ENTER , * "demo" , Keys .ENTER , Keys .ENTER ]
335+ steps = [Keys .ENTER , Keys .ENTER , * "demo" , Keys .ENTER , Keys .ENTER , Keys . ENTER ]
336336
337337 team = _get_random_team ()
338338
@@ -343,10 +343,50 @@ def test_creates_app_on_backend(
343343 )
344344 )
345345
346- respx_mock .post ("/apps/" , json = {"name" : "demo" , "team_id" : team ["id" ]}).mock (
347- return_value = Response (201 , json = _get_random_app (team_id = team ["id" ]))
346+ respx_mock .post (
347+ "/apps/" , json = {"name" : "demo" , "team_id" : team ["id" ], "directory" : None }
348+ ).mock (return_value = Response (201 , json = _get_random_app (team_id = team ["id" ])))
349+
350+ with (
351+ changing_dir (tmp_path ),
352+ patch ("rich_toolkit.container.getchar" ) as mock_getchar ,
353+ ):
354+ mock_getchar .side_effect = steps
355+
356+ result = runner .invoke (app , ["deploy" ])
357+
358+ assert result .exit_code == 1
359+
360+ assert "App created successfully" in result .output
361+
362+
363+ @pytest .mark .respx
364+ def test_creates_app_with_directory (
365+ logged_in_cli : None , tmp_path : Path , respx_mock : respx .MockRouter
366+ ) -> None :
367+ steps = [
368+ Keys .ENTER ,
369+ Keys .ENTER ,
370+ * "demo" ,
371+ Keys .ENTER ,
372+ * "src" ,
373+ Keys .ENTER ,
374+ Keys .ENTER ,
375+ ]
376+
377+ team = _get_random_team ()
378+
379+ respx_mock .get ("/teams/" ).mock (
380+ return_value = Response (
381+ 200 ,
382+ json = {"data" : [team ]},
383+ )
348384 )
349385
386+ respx_mock .post (
387+ "/apps/" , json = {"name" : "demo" , "team_id" : team ["id" ], "directory" : "src" }
388+ ).mock (return_value = Response (201 , json = _get_random_app (team_id = team ["id" ])))
389+
350390 with (
351391 changing_dir (tmp_path ),
352392 patch ("rich_toolkit.container.getchar" ) as mock_getchar ,
@@ -358,6 +398,7 @@ def test_creates_app_on_backend(
358398 assert result .exit_code == 1
359399
360400 assert "App created successfully" in result .output
401+ assert "Directory: src" in result .output
361402
362403
363404@pytest .mark .respx
@@ -369,6 +410,7 @@ def test_cancels_deployment_when_user_selects_no(
369410 Keys .ENTER ,
370411 * "demo" ,
371412 Keys .ENTER ,
413+ Keys .ENTER ,
372414 Keys .DOWN_ARROW ,
373415 Keys .ENTER ,
374416 ]
@@ -434,6 +476,7 @@ def test_exits_successfully_when_deployment_is_done(
434476 * "demo" ,
435477 Keys .ENTER ,
436478 Keys .ENTER ,
479+ Keys .ENTER ,
437480 ]
438481
439482 team_data = _get_random_team ()
@@ -443,9 +486,9 @@ def test_exits_successfully_when_deployment_is_done(
443486 return_value = Response (200 , json = {"data" : [team_data ]})
444487 )
445488
446- respx_mock .post ("/apps/" , json = { "name" : "demo" , "team_id" : team_data [ "id" ]}). mock (
447- return_value = Response ( 201 , json = app_data )
448- )
489+ respx_mock .post (
490+ "/apps/" , json = { "name" : "demo" , "team_id" : team_data [ "id" ], "directory" : None }
491+ ). mock ( return_value = Response ( 201 , json = app_data ))
449492
450493 respx_mock .get (f"/apps/{ app_data ['id' ]} " ).mock (
451494 return_value = Response (200 , json = app_data )
@@ -685,6 +728,7 @@ def _deploy_without_waiting(respx_mock: respx.MockRouter, tmp_path: Path) -> Res
685728 * "demo" ,
686729 Keys .ENTER ,
687730 Keys .ENTER ,
731+ Keys .ENTER ,
688732 ]
689733
690734 team_data = _get_random_team ()
@@ -698,9 +742,9 @@ def _deploy_without_waiting(respx_mock: respx.MockRouter, tmp_path: Path) -> Res
698742 )
699743 )
700744
701- respx_mock .post ("/apps/" , json = { "name" : "demo" , "team_id" : team_data [ "id" ]}). mock (
702- return_value = Response ( 201 , json = app_data )
703- )
745+ respx_mock .post (
746+ "/apps/" , json = { "name" : "demo" , "team_id" : team_data [ "id" ], "directory" : None }
747+ ). mock ( return_value = Response ( 201 , json = app_data ))
704748
705749 respx_mock .get (f"/apps/{ app_data ['id' ]} " ).mock (
706750 return_value = Response (200 , json = app_data )
0 commit comments