Coverage for tests/test_cli_logout.py: 100%
32 statements
« prev ^ index » next coverage.py v7.16.0, created at 2026-11-09 00:25 +0000
« prev ^ index » next coverage.py v7.16.0, created at 2026-11-09 00:25 +0000
1import json 1abcdefg
2from pathlib import Path 1abcdefg
4from typer.testing import CliRunner 1abcdefg
6from fastapi_cloud_cli.cli import cloud_app as app 1abcdefg
8runner = CliRunner() 1abcdefg
11def test_logout_with_existing_auth_file(temp_auth_config: Path) -> None: 1abcdefg
12 temp_auth_config.write_text('{"access_token": "test_token"}') 1hijklmn
14 assert temp_auth_config.exists() 1hijklmn
16 result = runner.invoke(app, ["logout"]) 1hijklmn
18 assert result.exit_code == 0 1hijklmn
19 assert "You are now logged out!" in result.output 1hijklmn
21 assert not temp_auth_config.exists() 1hijklmn
24def test_logout_with_no_auth_file(temp_auth_config: Path) -> None: 1abcdefg
25 assert not temp_auth_config.exists() 1CDEFGHI
27 result = runner.invoke(app, ["logout"]) 1CDEFGHI
29 assert result.exit_code == 0 1CDEFGHI
30 assert "You are now logged out!" in result.output 1CDEFGHI
32 assert not temp_auth_config.exists() 1CDEFGHI
35def test_logout_json_with_existing_auth_file(temp_auth_config: Path) -> None: 1abcdefg
36 temp_auth_config.write_text('{"access_token": "test_token"}') 1opqrstu
38 result = runner.invoke(app, ["logout", "--json"]) 1opqrstu
40 assert result.exit_code == 0 1opqrstu
41 assert json.loads(result.stdout) == {"data": {"logged_out": True}} 1opqrstu
42 assert result.stderr == "" 1opqrstu
43 assert not temp_auth_config.exists() 1opqrstu
46def test_logout_json_with_no_auth_file(temp_auth_config: Path) -> None: 1abcdefg
47 assert not temp_auth_config.exists() 1vwxyzAB
49 result = runner.invoke(app, ["logout", "--json"]) 1vwxyzAB
51 assert result.exit_code == 0 1vwxyzAB
52 assert json.loads(result.stdout) == {"data": {"logged_out": True}} 1vwxyzAB
53 assert result.stderr == "" 1vwxyzAB
54 assert not temp_auth_config.exists() 1vwxyzAB