55import pytest
66
77from gitingest .ignore_patterns import DEFAULT_IGNORE_PATTERNS
8- from gitingest .query_parser import _parse_patterns , _parse_url , parse_query
8+ from gitingest .query_parser import _parse_patterns , _parse_repo_source , parse_query
99
1010
1111async def test_parse_url_valid_https () -> None :
1212 """
13- Test `_parse_url ` with valid HTTPS URLs from supported platforms (GitHub, GitLab, Bitbucket, Gitea).
13+ Test `_parse_repo_source ` with valid HTTPS URLs from supported platforms (GitHub, GitLab, Bitbucket, Gitea).
1414 Verifies that user and repository names are correctly extracted.
1515 """
1616 test_cases = [
@@ -19,15 +19,15 @@ async def test_parse_url_valid_https() -> None:
1919 "https://bitbucket.org/user/repo" ,
2020 ]
2121 for url in test_cases :
22- result = await _parse_url (url )
22+ result = await _parse_repo_source (url )
2323 assert result ["user_name" ] == "user"
2424 assert result ["repo_name" ] == "repo"
2525 assert result ["url" ] == url
2626
2727
2828async def test_parse_url_valid_http () -> None :
2929 """
30- Test `_parse_url ` with valid HTTP URLs from supported platforms.
30+ Test `_parse_repo_source ` with valid HTTP URLs from supported platforms.
3131 Verifies that user and repository names, as well as the slug, are correctly extracted.
3232 """
3333 test_cases = [
@@ -36,20 +36,20 @@ async def test_parse_url_valid_http() -> None:
3636 "http://bitbucket.org/user/repo" ,
3737 ]
3838 for url in test_cases :
39- result = await _parse_url (url )
39+ result = await _parse_repo_source (url )
4040 assert result ["user_name" ] == "user"
4141 assert result ["repo_name" ] == "repo"
4242 assert result ["slug" ] == "user-repo"
4343
4444
4545async def test_parse_url_invalid () -> None :
4646 """
47- Test `_parse_url ` with an invalid URL that does not include a repository structure.
47+ Test `_parse_repo_source ` with an invalid URL that does not include a repository structure.
4848 Verifies that a ValueError is raised with an appropriate error message.
4949 """
5050 url = "https://github.com"
5151 with pytest .raises (ValueError , match = "Invalid repository URL" ):
52- await _parse_url (url )
52+ await _parse_repo_source (url )
5353
5454
5555async def test_parse_query_basic () -> None :
@@ -99,11 +99,11 @@ async def test_parse_query_invalid_pattern() -> None:
9999
100100async def test_parse_url_with_subpaths () -> None :
101101 """
102- Test `_parse_url ` with a URL containing a branch and subpath.
102+ Test `_parse_repo_source ` with a URL containing a branch and subpath.
103103 Verifies that user name, repository name, branch, and subpath are correctly extracted.
104104 """
105105 url = "https://github.com/user/repo/tree/main/subdir/file"
106- result = await _parse_url (url )
106+ result = await _parse_repo_source (url )
107107 assert result ["user_name" ] == "user"
108108 assert result ["repo_name" ] == "repo"
109109 assert result ["branch" ] == "main"
@@ -112,12 +112,12 @@ async def test_parse_url_with_subpaths() -> None:
112112
113113async def test_parse_url_invalid_repo_structure () -> None :
114114 """
115- Test `_parse_url ` with an invalid repository structure in the URL.
115+ Test `_parse_repo_source ` with an invalid repository structure in the URL.
116116 Verifies that a ValueError is raised with an appropriate error message.
117117 """
118118 url = "https://github.com/user"
119119 with pytest .raises (ValueError , match = "Invalid repository URL" ):
120- await _parse_url (url )
120+ await _parse_repo_source (url )
121121
122122
123123def test_parse_patterns_valid () -> None :
@@ -216,14 +216,14 @@ async def test_parse_query_empty_source() -> None:
216216
217217async def test_parse_url_branch_and_commit_distinction () -> None :
218218 """
219- Test `_parse_url ` with URLs containing either a branch name or a commit hash.
219+ Test `_parse_repo_source ` with URLs containing either a branch name or a commit hash.
220220 Verifies that the branch and commit are correctly distinguished.
221221 """
222222 url_branch = "https://github.com/user/repo/tree/main"
223223 url_commit = "https://github.com/user/repo/tree/abcd1234abcd1234abcd1234abcd1234abcd1234"
224224
225- result_branch = await _parse_url (url_branch )
226- result_commit = await _parse_url (url_commit )
225+ result_branch = await _parse_repo_source (url_branch )
226+ result_commit = await _parse_repo_source (url_commit )
227227
228228 assert result_branch ["branch" ] == "main"
229229 assert result_branch ["commit" ] is None
@@ -244,11 +244,11 @@ async def test_parse_query_uuid_uniqueness() -> None:
244244
245245async def test_parse_url_with_query_and_fragment () -> None :
246246 """
247- Test `_parse_url ` with a URL containing query parameters and a fragment.
247+ Test `_parse_repo_source ` with a URL containing query parameters and a fragment.
248248 Verifies that the URL is cleaned and other fields are correctly extracted.
249249 """
250250 url = "https://github.com/user/repo?arg=value#fragment"
251- result = await _parse_url (url )
251+ result = await _parse_repo_source (url )
252252 assert result ["user_name" ] == "user"
253253 assert result ["repo_name" ] == "repo"
254254 assert result ["url" ] == "https://github.com/user/repo" # URL should be cleaned
0 commit comments