File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -162,3 +162,24 @@ def test_fetch_access_token_handles_500_error(respx_mock: respx.MockRouter) -> N
162162 with APIClient () as client :
163163 with pytest .raises (httpx .HTTPStatusError ):
164164 _fetch_access_token (client , "test_device_code" , 5 )
165+
166+
167+ @pytest .mark .respx (base_url = settings .base_api_url )
168+ def test_notify_already_logged_in_user (
169+ respx_mock : respx .MockRouter , logged_in_cli : None
170+ ) -> None :
171+ respx_mock .get ("/users/me" ).mock (
172+ return_value = Response (200 , json = {"email" : "userme@example.com" })
173+ )
174+
175+ device_auth_mock = respx_mock .post (
176+ "/login/device/authorization" , data = {"client_id" : settings .client_id }
177+ ).mock (return_value = Response (200 , json = {}))
178+
179+ result = runner .invoke (app , ["login" ])
180+
181+ assert result .exit_code == 0
182+ assert "Already logged in as userme@example.com" in result .output
183+ assert "Run fastapi logout first if you want to switch accounts." in result .output
184+
185+ assert device_auth_mock .call_count == 0
You can’t perform that action at this time.
0 commit comments