1010from infrahub .core .constants import InfrahubKind , RepositoryInternalStatus
1111from infrahub .exceptions import RepositoryError
1212from infrahub .git import InfrahubRepository
13- from infrahub .git .models import GitRepositoryAdd , GitRepositoryMerge , GitRepositoryPullReadOnly
13+ from infrahub .git .models import (
14+ GitRepositoryAdd ,
15+ GitRepositoryAddReadOnly ,
16+ GitRepositoryMerge ,
17+ GitRepositoryPullReadOnly ,
18+ )
1419from infrahub .git .repository import InfrahubReadOnlyRepository
15- from infrahub .git .tasks import add_git_repository , pull_read_only
20+ from infrahub .git .tasks import add_git_repository , add_git_repository_read_only , pull_read_only
1621from infrahub .lock import InfrahubLockRegistry
1722from infrahub .message_bus import Meta , messages
18- from infrahub .message_bus .operations import git
1923from infrahub .services import InfrahubServices , services
2024from infrahub .services .adapters .workflow .local import WorkflowLocalExecution
2125from infrahub .workflows .catalogue import GIT_REPOSITORIES_MERGE
@@ -197,25 +201,26 @@ class TestAddReadOnly:
197201 def setup_method (self ):
198202 self .client = AsyncMock (spec = InfrahubClient )
199203 self .git_report = AsyncContextManagerMock ()
200- self .services = InfrahubServices (client = self .client )
201- self .services .git_report = self .git_report
202204
203- lock_patcher = patch ("infrahub.message_bus.operations.git.repository.lock" )
205+ self .original_services = services .service
206+ services .service = InfrahubServices (client = self .client )
207+ services .service .git_report = self .git_report
208+
209+ lock_patcher = patch ("infrahub.git.tasks.lock" )
204210 self .mock_infra_lock = lock_patcher .start ()
205211 self .mock_infra_lock .registry = AsyncMock (spec = InfrahubLockRegistry )
206- repo_class_patcher = patch (
207- "infrahub.message_bus.operations.git.repository.InfrahubReadOnlyRepository" , spec = InfrahubReadOnlyRepository
208- )
212+ repo_class_patcher = patch ("infrahub.git.tasks.InfrahubReadOnlyRepository" , spec = InfrahubReadOnlyRepository )
209213 self .mock_repo_class = repo_class_patcher .start ()
210214 self .mock_repo = AsyncMock (spec = InfrahubReadOnlyRepository )
211215 self .mock_repo_class .new .return_value = self .mock_repo
212216
213217 def teardown_method (self ):
214218 patch .stopall ()
219+ services .service = self .original_services
215220
216221 async def test_git_rpc_add_read_only_success (self , git_upstream_repo_01 : dict [str , str ]):
217222 repo_id = str (UUIDT ())
218- message = messages . GitRepositoryAddReadOnly (
223+ model = GitRepositoryAddReadOnly (
219224 repository_id = repo_id ,
220225 repository_name = git_upstream_repo_01 ["name" ],
221226 location = git_upstream_repo_01 ["path" ],
@@ -224,7 +229,7 @@ async def test_git_rpc_add_read_only_success(self, git_upstream_repo_01: dict[st
224229 internal_status = "active" ,
225230 )
226231
227- await git . repository . add_read_only ( message = message , service = self . services )
232+ await add_git_repository_read_only ( model = model )
228233
229234 self .mock_infra_lock .registry .get (name = git_upstream_repo_01 ["name" ], namespace = "repository" )
230235 self .mock_repo_class .new .assert_awaited_once_with (
0 commit comments