Coverage for tests/test_sentry.py: 100%

17 statements  

« prev     ^ index     » next       coverage.py v7.16.0, created at 2026-11-09 00:25 +0000

1from pathlib import Path 1abcdefg

2from unittest.mock import ANY, patch 1abcdefg

3 

4import pytest 1abcdefg

5 

6from fastapi_cloud_cli.utils.sentry import SENTRY_DSN, init_sentry 1abcdefg

7 

8 

9def test_init_sentry_when_logged_in(logged_in_cli: Path) -> None: 1abcdefg

10 with patch("fastapi_cloud_cli.utils.sentry.sentry_sdk.init") as mock_init: 1opqrstu

11 init_sentry() 1opqrstu

12 

13 mock_init.assert_called_once_with( 1opqrstu

14 dsn=SENTRY_DSN, 

15 integrations=[ANY], # TyperIntegration instance 

16 send_default_pii=False, 

17 ) 

18 

19 

20def test_init_sentry_when_deployment_token( 1abcdefg

21 logged_out_cli: Path, monkeypatch: pytest.MonkeyPatch 

22) -> None: 

23 monkeypatch.setenv("FASTAPI_CLOUD_TOKEN", "deployment-token") 1hijklmn

24 with patch("fastapi_cloud_cli.utils.sentry.sentry_sdk.init") as mock_init: 1hijklmn

25 init_sentry() 1hijklmn

26 

27 mock_init.assert_called_once_with( 1hijklmn

28 dsn=SENTRY_DSN, 

29 integrations=[ANY], # TyperIntegration instance 

30 send_default_pii=False, 

31 ) 

32 

33 

34def test_init_sentry_when_logged_out(logged_out_cli: Path) -> None: 1abcdefg

35 with patch("fastapi_cloud_cli.utils.sentry.sentry_sdk.init") as mock_init: 1vwxyzAB

36 init_sentry() 1vwxyzAB

37 

38 mock_init.assert_not_called() 1vwxyzAB