Skip to content

Commit 31756ce

Browse files
committed
tests/_internal/remotes(test[pagination]) Remove xfail markers from pagination tests
why: The pagination duplicate bug has been fixed in both GitHub and Gitea importers. what: - Remove @pytest.mark.xfail decorators from both tests - Tests now pass and verify consistent per_page/limit across all API requests
1 parent 651140d commit 31756ce

File tree

1 file changed

+24
-26
lines changed

1 file changed

+24
-26
lines changed

tests/_internal/remotes/test_pagination_duplicates.py

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,6 @@ def __exit__(self, *args: t.Any) -> None:
108108
pass
109109

110110

111-
@pytest.mark.xfail(
112-
reason="Pagination uses inconsistent per_page when client-side filtering is active"
113-
)
114111
def test_github_pagination_consistent_per_page(
115112
monkeypatch: pytest.MonkeyPatch,
116113
) -> None:
@@ -122,19 +119,19 @@ def test_github_pagination_consistent_per_page(
122119
"""
123120
captured_requests: list[urllib.request.Request] = []
124121

125-
# Create repos: mix of regular and forked
122+
# Create page 1 with exactly DEFAULT_PER_PAGE items to force pagination.
123+
# Half regular repos, half forks - forks will be filtered out client-side.
126124
page1_repos = [
127-
_make_github_repo("repo1"),
128-
_make_github_repo("repo2"),
129-
_make_github_repo("fork1", fork=True),
130-
_make_github_repo("fork2", fork=True),
131-
_make_github_repo("fork3", fork=True),
125+
_make_github_repo(f"repo{i}") for i in range(GITHUB_DEFAULT_PER_PAGE // 2)
132126
]
127+
page1_repos.extend(
128+
_make_github_repo(f"fork{i}", fork=True)
129+
for i in range(GITHUB_DEFAULT_PER_PAGE // 2)
130+
)
133131

132+
# Page 2 has more repos
134133
page2_repos = [
135-
_make_github_repo("repo3"),
136-
_make_github_repo("repo4"),
137-
_make_github_repo("repo5"),
134+
_make_github_repo(f"repo{GITHUB_DEFAULT_PER_PAGE // 2 + i}") for i in range(10)
138135
]
139136

140137
responses = [
@@ -164,10 +161,12 @@ def urlopen_capture(
164161
monkeypatch.setattr("urllib.request.urlopen", urlopen_capture)
165162

166163
importer = GitHubImporter()
164+
# Request more repos than page 1 provides after filtering (50 regular repos)
165+
# This forces pagination to continue to page 2
167166
options = ImportOptions(
168167
mode=ImportMode.USER,
169168
target="testuser",
170-
limit=5,
169+
limit=60, # More than 50 regular repos in page 1
171170
include_forks=False, # Filter out forks client-side
172171
)
173172
list(importer.fetch_repos(options))
@@ -188,9 +187,6 @@ def urlopen_capture(
188187
)
189188

190189

191-
@pytest.mark.xfail(
192-
reason="Pagination uses inconsistent limit when client-side filtering is active"
193-
)
194190
def test_gitea_pagination_consistent_limit(
195191
monkeypatch: pytest.MonkeyPatch,
196192
) -> None:
@@ -202,19 +198,19 @@ def test_gitea_pagination_consistent_limit(
202198
"""
203199
captured_requests: list[urllib.request.Request] = []
204200

205-
# Create repos: mix of regular and forked
201+
# Create page 1 with exactly DEFAULT_PER_PAGE items to force pagination.
202+
# Half regular repos, half forks - forks will be filtered out client-side.
206203
page1_repos = [
207-
_make_gitea_repo("repo1"),
208-
_make_gitea_repo("repo2"),
209-
_make_gitea_repo("fork1", fork=True),
210-
_make_gitea_repo("fork2", fork=True),
211-
_make_gitea_repo("fork3", fork=True),
204+
_make_gitea_repo(f"repo{i}") for i in range(GITEA_DEFAULT_PER_PAGE // 2)
212205
]
206+
page1_repos.extend(
207+
_make_gitea_repo(f"fork{i}", fork=True)
208+
for i in range(GITEA_DEFAULT_PER_PAGE // 2)
209+
)
213210

211+
# Page 2 has more repos
214212
page2_repos = [
215-
_make_gitea_repo("repo3"),
216-
_make_gitea_repo("repo4"),
217-
_make_gitea_repo("repo5"),
213+
_make_gitea_repo(f"repo{GITEA_DEFAULT_PER_PAGE // 2 + i}") for i in range(10)
218214
]
219215

220216
responses: list[tuple[bytes, dict[str, str], int]] = [
@@ -236,10 +232,12 @@ def urlopen_capture(
236232
monkeypatch.setattr("urllib.request.urlopen", urlopen_capture)
237233

238234
importer = GiteaImporter(base_url="https://codeberg.org")
235+
# Request more repos than page 1 provides after filtering (25 regular repos)
236+
# This forces pagination to continue to page 2
239237
options = ImportOptions(
240238
mode=ImportMode.USER,
241239
target="testuser",
242-
limit=5,
240+
limit=35, # More than 25 regular repos in page 1
243241
include_forks=False, # Filter out forks client-side
244242
)
245243
list(importer.fetch_repos(options))

0 commit comments

Comments
 (0)