@@ -67,22 +67,22 @@ class TestFetchFileFromGh:
6767 async def test_fetch_file_success (self ):
6868 resp = _make_response (text = SAMPLE_FILE_CONTENT )
6969 with patch .object (gfv_mod , "call_api" , new_callable = AsyncMock , return_value = resp ):
70- result = await gfv_mod .fetch_file_from_gh . fn (owner = "Owner" , repo = "Repo" , path = "src/main.py" )
70+ result = await gfv_mod .fetch_file_from_gh (owner = "Owner" , repo = "Repo" , path = "src/main.py" )
7171 assert "1: import os" in result
7272 assert "5: print(\" Setec Astronomy\" )" in result
7373
7474 @pytest .mark .asyncio
7575 async def test_fetch_file_lowercases_owner_repo (self ):
7676 resp = _make_response (text = "line1\n line2\n " )
7777 with patch .object (gfv_mod , "call_api" , new_callable = AsyncMock , return_value = resp ) as mock_api :
78- await gfv_mod .fetch_file_from_gh . fn (owner = "OWNER" , repo = "REPO" , path = "file.py" )
78+ await gfv_mod .fetch_file_from_gh (owner = "OWNER" , repo = "REPO" , path = "file.py" )
7979 url = mock_api .call_args [1 ]["url" ]
8080 assert "/owner/repo/" in url
8181
8282 @pytest .mark .asyncio
8383 async def test_fetch_file_api_error (self ):
8484 with patch .object (gfv_mod , "call_api" , new_callable = AsyncMock , return_value = "HTTP error: 404" ):
85- result = await gfv_mod .fetch_file_from_gh . fn (owner = "owner" , repo = "repo" , path = "missing.py" )
85+ result = await gfv_mod .fetch_file_from_gh (owner = "owner" , repo = "repo" , path = "missing.py" )
8686 assert result == "HTTP error: 404"
8787
8888
@@ -95,7 +95,7 @@ class TestGetFileLinesFromGh:
9595 async def test_get_lines_range (self ):
9696 resp = _make_response (text = SAMPLE_FILE_CONTENT )
9797 with patch .object (gfv_mod , "call_api" , new_callable = AsyncMock , return_value = resp ):
98- result = await gfv_mod .get_file_lines_from_gh . fn (
98+ result = await gfv_mod .get_file_lines_from_gh (
9999 owner = "owner" , repo = "repo" , path = "main.py" , start_line = 4 , length = 2
100100 )
101101 lines = result .strip ().splitlines ()
@@ -106,7 +106,7 @@ async def test_get_lines_range(self):
106106 async def test_get_lines_clamps_start (self ):
107107 resp = _make_response (text = SAMPLE_FILE_CONTENT )
108108 with patch .object (gfv_mod , "call_api" , new_callable = AsyncMock , return_value = resp ):
109- result = await gfv_mod .get_file_lines_from_gh . fn (
109+ result = await gfv_mod .get_file_lines_from_gh (
110110 owner = "owner" , repo = "repo" , path = "main.py" , start_line = - 5 , length = 2
111111 )
112112 assert "1: import os" in result
@@ -115,15 +115,15 @@ async def test_get_lines_clamps_start(self):
115115 async def test_get_lines_out_of_range (self ):
116116 resp = _make_response (text = "one\n two\n " )
117117 with patch .object (gfv_mod , "call_api" , new_callable = AsyncMock , return_value = resp ):
118- result = await gfv_mod .get_file_lines_from_gh . fn (
118+ result = await gfv_mod .get_file_lines_from_gh (
119119 owner = "owner" , repo = "repo" , path = "main.py" , start_line = 100 , length = 10
120120 )
121121 assert "No lines found" in result
122122
123123 @pytest .mark .asyncio
124124 async def test_get_lines_api_error (self ):
125125 with patch .object (gfv_mod , "call_api" , new_callable = AsyncMock , return_value = "Request error: timeout" ):
126- result = await gfv_mod .get_file_lines_from_gh . fn (
126+ result = await gfv_mod .get_file_lines_from_gh (
127127 owner = "owner" , repo = "repo" , path = "main.py" , start_line = 1 , length = 5
128128 )
129129 assert result == "Request error: timeout"
@@ -138,7 +138,7 @@ class TestSearchFileFromGh:
138138 async def test_search_file_finds_matches (self ):
139139 resp = _make_response (text = SAMPLE_FILE_CONTENT )
140140 with patch .object (gfv_mod , "call_api" , new_callable = AsyncMock , return_value = resp ):
141- result = await gfv_mod .search_file_from_gh . fn (
141+ result = await gfv_mod .search_file_from_gh (
142142 owner = "owner" , repo = "repo" , path = "main.py" , search_term = "import"
143143 )
144144 assert "1: import os" in result
@@ -148,15 +148,15 @@ async def test_search_file_finds_matches(self):
148148 async def test_search_file_no_matches (self ):
149149 resp = _make_response (text = SAMPLE_FILE_CONTENT )
150150 with patch .object (gfv_mod , "call_api" , new_callable = AsyncMock , return_value = resp ):
151- result = await gfv_mod .search_file_from_gh . fn (
151+ result = await gfv_mod .search_file_from_gh (
152152 owner = "owner" , repo = "repo" , path = "main.py" , search_term = "nonexistent_term"
153153 )
154154 assert "No matches found" in result
155155
156156 @pytest .mark .asyncio
157157 async def test_search_file_api_error (self ):
158158 with patch .object (gfv_mod , "call_api" , new_callable = AsyncMock , return_value = "HTTP error: 500" ):
159- result = await gfv_mod .search_file_from_gh . fn (
159+ result = await gfv_mod .search_file_from_gh (
160160 owner = "owner" , repo = "repo" , path = "main.py" , search_term = "import"
161161 )
162162 assert result == "HTTP error: 500"
@@ -171,7 +171,7 @@ class TestSearchFilesFromGh:
171171 async def test_search_files_multiple_paths (self ):
172172 resp = _make_response (text = SAMPLE_FILE_CONTENT )
173173 with patch .object (gfv_mod , "call_api" , new_callable = AsyncMock , return_value = resp ):
174- result = await gfv_mod .search_files_from_gh . fn (
174+ result = await gfv_mod .search_files_from_gh (
175175 owner = "owner" , repo = "repo" , paths = "main.py, utils.py" , search_term = "import" ,
176176 save_to_db = False ,
177177 )
@@ -183,7 +183,7 @@ async def test_search_files_multiple_paths(self):
183183 async def test_search_files_no_paths (self ):
184184 resp = _make_response (text = "" )
185185 with patch .object (gfv_mod , "call_api" , new_callable = AsyncMock , return_value = resp ):
186- result = await gfv_mod .search_files_from_gh . fn (
186+ result = await gfv_mod .search_files_from_gh (
187187 owner = "owner" , repo = "repo" , paths = "" , search_term = "import" , save_to_db = False ,
188188 )
189189 # empty string split yields [""], which hits the API for an empty path
@@ -193,7 +193,7 @@ async def test_search_files_no_paths(self):
193193 async def test_search_files_no_matches (self ):
194194 resp = _make_response (text = "nothing here\n " )
195195 with patch .object (gfv_mod , "call_api" , new_callable = AsyncMock , return_value = resp ):
196- result = await gfv_mod .search_files_from_gh . fn (
196+ result = await gfv_mod .search_files_from_gh (
197197 owner = "owner" , repo = "repo" , paths = "main.py" , search_term = "zzzzz"
198198 )
199199 assert "No matches found" in result
@@ -208,7 +208,7 @@ async def test_search_files_save_to_db(self):
208208 mock_session = MagicMock ()
209209 mock_session_cls .return_value .__enter__ = MagicMock (return_value = mock_session )
210210 mock_session_cls .return_value .__exit__ = MagicMock (return_value = False )
211- result = await gfv_mod .search_files_from_gh . fn (
211+ result = await gfv_mod .search_files_from_gh (
212212 owner = "owner" , repo = "repo" , paths = "main.py" , search_term = "import" , save_to_db = True
213213 )
214214 assert "saved to database" in result
@@ -218,7 +218,7 @@ async def test_search_files_save_to_db(self):
218218 @pytest .mark .asyncio
219219 async def test_search_files_api_error (self ):
220220 with patch .object (gfv_mod , "call_api" , new_callable = AsyncMock , return_value = "Request error: timeout" ):
221- result = await gfv_mod .search_files_from_gh . fn (
221+ result = await gfv_mod .search_files_from_gh (
222222 owner = "owner" , repo = "repo" , paths = "main.py" , search_term = "import"
223223 )
224224 assert result == "Request error: timeout"
@@ -244,7 +244,7 @@ def test_fetch_last_results(self):
244244 mock_session .query .return_value .all .return_value = [mock_result ]
245245 mock_session .query .return_value .delete .return_value = None
246246
247- result = gfv_mod .fetch_last_search_results . fn ()
247+ result = gfv_mod .fetch_last_search_results ()
248248 data = json .loads (result )
249249 assert len (data ) == 1
250250 assert data [0 ]["path" ] == "src/main.py"
@@ -258,7 +258,7 @@ def test_fetch_last_results_empty(self):
258258 mock_session .query .return_value .all .return_value = []
259259 mock_session .query .return_value .delete .return_value = None
260260
261- result = gfv_mod .fetch_last_search_results . fn ()
261+ result = gfv_mod .fetch_last_search_results ()
262262 assert json .loads (result ) == []
263263
264264
@@ -271,7 +271,7 @@ class TestListDirectoryFromGh:
271271 async def test_list_directory_success (self ):
272272 resp = _make_response (json_data = SAMPLE_DIR_JSON )
273273 with patch .object (gfv_mod , "call_api" , new_callable = AsyncMock , return_value = resp ):
274- result = await gfv_mod .list_directory_from_gh . fn (owner = "Owner" , repo = "Repo" , path = "src" )
274+ result = await gfv_mod .list_directory_from_gh (owner = "Owner" , repo = "Repo" , path = "src" )
275275 data = json .loads (result )
276276 assert "src/main.py" in data
277277 assert "src/utils.py" in data
@@ -281,13 +281,13 @@ async def test_list_directory_success(self):
281281 async def test_list_directory_empty (self ):
282282 resp = _make_response (json_data = [])
283283 with patch .object (gfv_mod , "call_api" , new_callable = AsyncMock , return_value = resp ):
284- result = await gfv_mod .list_directory_from_gh . fn (owner = "owner" , repo = "repo" , path = "empty" )
284+ result = await gfv_mod .list_directory_from_gh (owner = "owner" , repo = "repo" , path = "empty" )
285285 assert json .loads (result ) == []
286286
287287 @pytest .mark .asyncio
288288 async def test_list_directory_api_error (self ):
289289 with patch .object (gfv_mod , "call_api" , new_callable = AsyncMock , return_value = "HTTP error: 404" ):
290- result = await gfv_mod .list_directory_from_gh . fn (owner = "owner" , repo = "repo" , path = "missing" )
290+ result = await gfv_mod .list_directory_from_gh (owner = "owner" , repo = "repo" , path = "missing" )
291291 assert result == "HTTP error: 404"
292292
293293 @pytest .mark .asyncio
@@ -296,7 +296,7 @@ async def test_list_directory_path_is_file(self):
296296 file_obj = {"path" : "src/main.py" , "type" : "file" , "size" : 123 , "sha" : "abc" }
297297 resp = _make_response (json_data = file_obj )
298298 with patch .object (gfv_mod , "call_api" , new_callable = AsyncMock , return_value = resp ):
299- result = await gfv_mod .list_directory_from_gh . fn (owner = "owner" , repo = "repo" , path = "src/main.py" )
299+ result = await gfv_mod .list_directory_from_gh (owner = "owner" , repo = "repo" , path = "src/main.py" )
300300 assert "not a directory" in result
301301
302302
@@ -318,7 +318,7 @@ async def fake_fetch_source_zip(owner, repo, tmp_dir):
318318 return "source code fetched"
319319
320320 with patch .object (gfv_mod , "_fetch_source_zip" , side_effect = fake_fetch_source_zip ):
321- result = await gfv_mod .search_repo_from_gh . fn (
321+ result = await gfv_mod .search_repo_from_gh (
322322 owner = "Owner" , repo = "Repo" , search_term = "import"
323323 )
324324 data = json .loads (result )
@@ -337,7 +337,7 @@ async def fake_fetch_source_zip(owner, repo, tmp_dir):
337337 return "source code fetched"
338338
339339 with patch .object (gfv_mod , "_fetch_source_zip" , side_effect = fake_fetch_source_zip ):
340- result = await gfv_mod .search_repo_from_gh . fn (
340+ result = await gfv_mod .search_repo_from_gh (
341341 owner = "owner" , repo = "repo" , search_term = "nonexistent"
342342 )
343343 assert json .loads (result ) == []
@@ -348,7 +348,7 @@ async def fake_fetch_source_zip(owner, repo, tmp_dir):
348348 return "Error: HTTP error: 404"
349349
350350 with patch .object (gfv_mod , "_fetch_source_zip" , side_effect = fake_fetch_source_zip ):
351- result = await gfv_mod .search_repo_from_gh . fn (
351+ result = await gfv_mod .search_repo_from_gh (
352352 owner = "owner" , repo = "repo" , search_term = "import"
353353 )
354354 data = json .loads (result )
0 commit comments