1- """ Tests for the clone module. """
1+ """ Tests for the repository_clone module. """
22
33from unittest .mock import AsyncMock , patch
44
55import pytest
66
7- from gitingest .clone import CloneConfig , _check_repo_exists , clone_repo
7+ from gitingest .repository_clone import CloneConfig , _check_repo_exists , clone_repo
88
99
1010@pytest .mark .asyncio
@@ -20,8 +20,8 @@ async def test_clone_repo_with_commit() -> None:
2020 branch = "main" ,
2121 )
2222
23- with patch ("gitingest.clone ._check_repo_exists" , return_value = True ) as mock_check :
24- with patch ("gitingest.clone ._run_git_command" , new_callable = AsyncMock ) as mock_exec :
23+ with patch ("gitingest.repository_clone ._check_repo_exists" , return_value = True ) as mock_check :
24+ with patch ("gitingest.repository_clone ._run_git_command" , new_callable = AsyncMock ) as mock_exec :
2525 mock_process = AsyncMock ()
2626 mock_process .communicate .return_value = (b"output" , b"error" )
2727 mock_exec .return_value = mock_process
@@ -38,8 +38,8 @@ async def test_clone_repo_without_commit() -> None:
3838 """
3939 query = CloneConfig (url = "https://github.com/user/repo" , local_path = "/tmp/repo" , commit = None , branch = "main" )
4040
41- with patch ("gitingest.clone ._check_repo_exists" , return_value = True ) as mock_check :
42- with patch ("gitingest.clone ._run_git_command" , new_callable = AsyncMock ) as mock_exec :
41+ with patch ("gitingest.repository_clone ._check_repo_exists" , return_value = True ) as mock_check :
42+ with patch ("gitingest.repository_clone ._run_git_command" , new_callable = AsyncMock ) as mock_exec :
4343 mock_process = AsyncMock ()
4444 mock_process .communicate .return_value = (b"output" , b"error" )
4545 mock_exec .return_value = mock_process
@@ -61,7 +61,7 @@ async def test_clone_repo_nonexistent_repository() -> None:
6161 commit = None ,
6262 branch = "main" ,
6363 )
64- with patch ("gitingest.clone ._check_repo_exists" , return_value = False ) as mock_check :
64+ with patch ("gitingest.repository_clone ._check_repo_exists" , return_value = False ) as mock_check :
6565 with pytest .raises (ValueError , match = "Repository not found" ):
6666 await clone_repo (clone_config )
6767 mock_check .assert_called_once_with (clone_config .url )
@@ -133,8 +133,8 @@ async def test_clone_repo_with_custom_branch() -> None:
133133 local_path = "/tmp/repo" ,
134134 branch = "feature-branch" ,
135135 )
136- with patch ("gitingest.clone ._check_repo_exists" , return_value = True ):
137- with patch ("gitingest.clone ._run_git_command" , new_callable = AsyncMock ) as mock_exec :
136+ with patch ("gitingest.repository_clone ._check_repo_exists" , return_value = True ):
137+ with patch ("gitingest.repository_clone ._run_git_command" , new_callable = AsyncMock ) as mock_exec :
138138 await clone_repo (clone_config )
139139 mock_exec .assert_called_once_with (
140140 "git" ,
@@ -158,8 +158,8 @@ async def test_git_command_failure() -> None:
158158 url = "https://github.com/user/repo" ,
159159 local_path = "/tmp/repo" ,
160160 )
161- with patch ("gitingest.clone ._check_repo_exists" , return_value = True ):
162- with patch ("gitingest.clone ._run_git_command" , side_effect = RuntimeError ("Git command failed" )):
161+ with patch ("gitingest.repository_clone ._check_repo_exists" , return_value = True ):
162+ with patch ("gitingest.repository_clone ._run_git_command" , side_effect = RuntimeError ("Git command failed" )):
163163 with pytest .raises (RuntimeError , match = "Git command failed" ):
164164 await clone_repo (clone_config )
165165
@@ -174,8 +174,8 @@ async def test_clone_repo_default_shallow_clone() -> None:
174174 url = "https://github.com/user/repo" ,
175175 local_path = "/tmp/repo" ,
176176 )
177- with patch ("gitingest.clone ._check_repo_exists" , return_value = True ):
178- with patch ("gitingest.clone ._run_git_command" , new_callable = AsyncMock ) as mock_exec :
177+ with patch ("gitingest.repository_clone ._check_repo_exists" , return_value = True ):
178+ with patch ("gitingest.repository_clone ._run_git_command" , new_callable = AsyncMock ) as mock_exec :
179179 await clone_repo (clone_config )
180180 mock_exec .assert_called_once_with (
181181 "git" , "clone" , "--depth=1" , "--single-branch" , clone_config .url , clone_config .local_path
@@ -193,8 +193,8 @@ async def test_clone_repo_commit_without_branch() -> None:
193193 local_path = "/tmp/repo" ,
194194 commit = "a" * 40 , # Simulating a valid commit hash
195195 )
196- with patch ("gitingest.clone ._check_repo_exists" , return_value = True ):
197- with patch ("gitingest.clone ._run_git_command" , new_callable = AsyncMock ) as mock_exec :
196+ with patch ("gitingest.repository_clone ._check_repo_exists" , return_value = True ):
197+ with patch ("gitingest.repository_clone ._run_git_command" , new_callable = AsyncMock ) as mock_exec :
198198 await clone_repo (clone_config )
199199 assert mock_exec .call_count == 2 # Clone and checkout calls
200200 mock_exec .assert_any_call ("git" , "clone" , "--single-branch" , clone_config .url , clone_config .local_path )
0 commit comments