@@ -60,12 +60,13 @@ def test_config_init(
6060 mock_github_manager .assert_called_once ()
6161
6262
63- @patch ("git_portfolio.__main__.CONFIG_MANAGER" )
63+ @patch ("git_portfolio.__main__.CONFIG_MANAGER" , autospec = True )
6464@patch ("git_portfolio.github_manager.GithubManager" , autospec = True )
65- def test_config_repos (
65+ def test_config_repos_success (
6666 mock_github_manager : Mock , mock_configmanager : Mock , runner : CliRunner
6767) -> None :
6868 """It call config_repos from pm.GithubManager."""
69+ mock_configmanager .config_is_empty .return_value = False
6970 result = runner .invoke (
7071 git_portfolio .__main__ .configure , ["repos" ], prog_name = "gitp"
7172 )
@@ -74,6 +75,22 @@ def test_config_repos(
7475 assert result .output == "gitp successfully configured.\n "
7576
7677
78+ @patch ("git_portfolio.__main__.CONFIG_MANAGER" , autospec = True )
79+ @patch ("git_portfolio.github_manager.GithubManager" , autospec = True )
80+ def test_config_repos_do_not_change (
81+ mock_github_manager : Mock , mock_configmanager : Mock , runner : CliRunner
82+ ) -> None :
83+ """It does not change config file."""
84+ mock_configmanager .config_is_empty .return_value = False
85+ mock_github_manager .return_value .config_repos .return_value = None
86+ result = runner .invoke (
87+ git_portfolio .__main__ .configure , ["repos" ], prog_name = "gitp"
88+ )
89+ mock_github_manager .assert_called_once ()
90+ mock_github_manager .return_value .config_repos .assert_called_once ()
91+ assert "gitp successfully configured.\n " not in result .output
92+
93+
7794@patch ("git_portfolio.__main__.CONFIG_MANAGER" )
7895@patch ("git_portfolio.github_manager.GithubManager" , autospec = True )
7996def test_config_repos_no_config (
@@ -84,8 +101,6 @@ def test_config_repos_no_config(
84101 result = runner .invoke (
85102 git_portfolio .__main__ .configure , ["repos" ], prog_name = "gitp"
86103 )
87- mock_github_manager .assert_called_once ()
88- mock_github_manager .return_value .config_repos .assert_called_once ()
89104 assert "Error" in result .output
90105
91106
0 commit comments