@@ -60,10 +60,63 @@ def _get_random_deployment(
6060
6161
6262@pytest .mark .respx (base_url = settings .base_api_url )
63- def test_shows_waitlist_form_when_not_logged_in (
63+ def test_chooses_login_option_when_not_logged_in (
6464 logged_out_cli : None , tmp_path : Path , respx_mock : respx .MockRouter
6565) -> None :
66- steps = [
* "[email protected] " ,
Keys .
ENTER ,
Keys .
RIGHT_ARROW ,
Keys .
ENTER ,
Keys .
ENTER ]
66+ steps = [Keys .ENTER ]
67+
68+ respx_mock .post (
69+ "/login/device/authorization" , data = {"client_id" : settings .client_id }
70+ ).mock (
71+ return_value = Response (
72+ 200 ,
73+ json = {
74+ "verification_uri_complete" : "http://test.com" ,
75+ "verification_uri" : "http://test.com" ,
76+ "user_code" : "1234" ,
77+ "device_code" : "5678" ,
78+ },
79+ )
80+ )
81+ respx_mock .post (
82+ "/login/device/token" ,
83+ data = {
84+ "device_code" : "5678" ,
85+ "client_id" : settings .client_id ,
86+ "grant_type" : "urn:ietf:params:oauth:grant-type:device_code" ,
87+ },
88+ ).mock (return_value = Response (200 , json = {"access_token" : "test_token_1234" }))
89+
90+ with changing_dir (tmp_path ), patch (
91+ "rich_toolkit.container.getchar"
92+ ) as mock_getchar , patch (
93+ "fastapi_cloud_cli.commands.login.typer.launch"
94+ ) as mock_launch :
95+ mock_getchar .side_effect = steps
96+
97+ result = runner .invoke (app , ["deploy" ])
98+
99+ assert "Welcome to FastAPI Cloud!" in result .output
100+ assert "What would you like to do?" in result .output
101+ assert "Login to my existing account" in result .output
102+ assert "Join the waiting list" in result .output
103+ assert "Now you are logged in!" in result .output
104+ assert mock_launch .called
105+
106+
107+ @pytest .mark .respx (base_url = settings .base_api_url )
108+ def test_chooses_waitlist_option_when_not_logged_in (
109+ logged_out_cli : None , tmp_path : Path , respx_mock : respx .MockRouter
110+ ) -> None :
111+ steps = [
112+ Keys .DOWN_ARROW ,
113+ Keys .ENTER ,
114+ 115+ Keys .ENTER ,
116+ Keys .RIGHT_ARROW ,
117+ Keys .ENTER ,
118+ Keys .ENTER ,
119+ ]
67120
68121 respx_mock .post (
69122 "/users/waiting-list" ,
@@ -87,6 +140,10 @@ def test_shows_waitlist_form_when_not_logged_in(
87140 result = runner .invoke (app , ["deploy" ])
88141
89142 assert result .exit_code == 1
143+ assert "Welcome to FastAPI Cloud!" in result .output
144+ assert "What would you like to do?" in result .output
145+ assert "Login to my existing account" in result .output
146+ assert "Join the waiting list" in result .output
90147 assert "We're currently in private beta" in result .output
91148 assert "Let's go! Thanks for your interest in FastAPI Cloud! 🚀" in result .output
92149
0 commit comments