Skip to content

Commit 9e3fc1f

Browse files
committed
test(import[gitlab]) Add search mode API test for with_shared absence
why: test_gitlab_with_shared_not_sent_in_user_mode existed for user mode but search mode was unasserted; search uses a separate /search endpoint that never calls _paginate_repos. what: - Add test_gitlab_with_shared_not_sent_in_search_mode mirroring user-mode test
1 parent ca1532c commit 9e3fc1f

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

tests/_internal/remotes/test_gitlab.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -964,6 +964,38 @@ def urlopen_capture(
964964
)
965965

966966

967+
def test_gitlab_with_shared_not_sent_in_search_mode(
968+
monkeypatch: pytest.MonkeyPatch,
969+
) -> None:
970+
"""Test that with_shared is NOT sent to GitLab API in search mode."""
971+
captured_urls: list[str] = []
972+
973+
response_json = [_make_group_project()]
974+
975+
def urlopen_capture(
976+
request: urllib.request.Request,
977+
timeout: int | None = None,
978+
) -> MockHTTPResponse:
979+
captured_urls.append(request.full_url)
980+
return MockHTTPResponse(json.dumps(response_json).encode())
981+
982+
# Mock urlopen: verify with_shared is absent from search-mode API calls
983+
monkeypatch.setattr("urllib.request.urlopen", urlopen_capture)
984+
985+
# Search mode requires authentication; token="fake" satisfies is_authenticated
986+
importer = GitLabImporter(token="fake")
987+
options = ImportOptions(
988+
mode=ImportMode.SEARCH, target="testsearch", with_shared=True
989+
)
990+
list(importer.fetch_repos(options))
991+
992+
assert len(captured_urls) == 1
993+
qs = urllib.parse.parse_qs(urllib.parse.urlsplit(captured_urls[0]).query)
994+
assert "with_shared" not in qs, (
995+
f"Expected no with_shared param in search-mode URL, got: {captured_urls[0]}"
996+
)
997+
998+
967999
# ---------------------------------------------------------------------------
9681000
# skip_groups filtering tests
9691001
# ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)