88
99from infrahub_sdk .client import InfrahubClient
1010from infrahub_sdk .ctl .cli_commands import app
11+ from tests .helpers .fixtures import read_fixture
12+ from tests .helpers .utils import strip_color
1113
1214runner = CliRunner ()
1315
@@ -24,11 +26,11 @@ def mock_client() -> mock.Mock:
2426# ---------------------------------------------------------
2527# infrahubctl repository command tests
2628# ---------------------------------------------------------
27- @mock .patch ("infrahub_sdk.ctl.repository.initialize_client" )
2829class TestInfrahubctlRepository :
2930 """Groups the 'infrahubctl repository' test cases."""
3031
3132 @requires_python_310
33+ @mock .patch ("infrahub_sdk.ctl.repository.initialize_client" )
3234 def test_repo_no_username (self , mock_init_client , mock_client ) -> None :
3335 """Case allow no username to be passed in and set it as None rather than blank string that fails."""
3436 mock_cred = mock .AsyncMock ()
@@ -89,6 +91,7 @@ def test_repo_no_username(self, mock_init_client, mock_client) -> None:
8991 )
9092
9193 @requires_python_310
94+ @mock .patch ("infrahub_sdk.ctl.repository.initialize_client" )
9295 def test_repo_username (self , mock_init_client , mock_client ) -> None :
9396 """Case allow no username to be passed in and set it as None rather than blank string that fails."""
9497 mock_cred = mock .AsyncMock ()
@@ -151,6 +154,7 @@ def test_repo_username(self, mock_init_client, mock_client) -> None:
151154 )
152155
153156 @requires_python_310
157+ @mock .patch ("infrahub_sdk.ctl.repository.initialize_client" )
154158 def test_repo_readonly_true (self , mock_init_client , mock_client ) -> None :
155159 """Case allow no username to be passed in and set it as None rather than blank string that fails."""
156160 mock_cred = mock .AsyncMock ()
@@ -212,6 +216,7 @@ def test_repo_readonly_true(self, mock_init_client, mock_client) -> None:
212216 )
213217
214218 @requires_python_310
219+ @mock .patch ("infrahub_sdk.ctl.repository.initialize_client" )
215220 def test_repo_description_commit_branch (self , mock_init_client , mock_client ) -> None :
216221 """Case allow no username to be passed in and set it as None rather than blank string that fails."""
217222 mock_cred = mock .AsyncMock ()
@@ -278,3 +283,8 @@ def test_repo_description_commit_branch(self, mock_init_client, mock_client) ->
278283 branch_name = "develop" ,
279284 tracker = "mutation-repository-create" ,
280285 )
286+
287+ def test_repo_list (self , mock_repositories_list ) -> None :
288+ result = runner .invoke (app , ["repository" , "list" , "--branch" , "main" ])
289+ assert result .exit_code == 0
290+ assert strip_color (result .stdout ) == read_fixture ("output.txt" , "integration/test_infrahubctl/repository_list" )
0 commit comments