Coverage for cli / tests / test_is_default_branch_deprecation.py: 100%

31 statements  

« prev     ^ index     » next       coverage.py v7.14.0, created at 2026-06-19 09:10 +0000

1from unittest.mock import AsyncMock 

2 

3import pytest 

4from typer.testing import CliRunner 

5 

6from covered.cli import app 

7from utils import COMMON_ENV 

8 

9runner = CliRunner() 

10 

11 

12def test_is_default_branch_true(mock_main: AsyncMock): 

13 with ( 

14 pytest.warns( 

15 DeprecationWarning, 

16 match=( 

17 "The `--is-default-branch` option is deprecated and will be removed in " 

18 "a future release. Please use `--purge-cache` instead." 

19 ), 

20 ), 

21 ): 

22 result = runner.invoke(app, [".", "--is-default-branch"], env=COMMON_ENV) 

23 

24 assert result.exit_code == 0, result.stderr 

25 

26 mock_main.assert_awaited_once() 

27 

28 call_args = mock_main.call_args_list[0] 

29 purge_cache_arg = call_args.kwargs.get("purge_cache") 

30 assert purge_cache_arg is True 

31 

32 

33def test_is_default_branch_false(mock_main: AsyncMock): 

34 with ( 

35 pytest.warns( 

36 DeprecationWarning, 

37 match=( 

38 "The `--is-default-branch` option is deprecated and will be removed in " 

39 "a future release. Please use `--purge-cache` instead." 

40 ), 

41 ), 

42 ): 

43 result = runner.invoke(app, [".", "--no-is-default-branch"], env=COMMON_ENV) 

44 

45 assert result.exit_code == 0, result.stderr 

46 

47 mock_main.assert_awaited_once() 

48 

49 call_args = mock_main.call_args_list[0] 

50 purge_cache_arg = call_args.kwargs.get("purge_cache") 

51 assert purge_cache_arg is False 

52 

53 

54@pytest.mark.parametrize( 

55 "is_default_branch_flag", 

56 [ 

57 "--is-default-branch", 

58 "--no-is-default-branch", 

59 ], 

60) 

61def test_is_default_branch_and_purge_cache( 

62 is_default_branch_flag: str, mock_main: AsyncMock 

63): 

64 with ( 

65 pytest.warns( 

66 DeprecationWarning, 

67 match=( 

68 "The `--is-default-branch` option is deprecated and will be removed in " 

69 "a future release. Please use `--purge-cache` instead." 

70 ), 

71 ), 

72 ): 

73 result = runner.invoke( 

74 app, [".", is_default_branch_flag, "--purge-cache"], env=COMMON_ENV 

75 ) 

76 

77 assert result.exit_code == 0, result.stderr 

78 

79 mock_main.assert_awaited_once() 

80 

81 call_args = mock_main.call_args_list[0] 

82 purge_cache_arg = call_args.kwargs.get("purge_cache") 

83 assert purge_cache_arg is True