MCPcopy
hub / github.com/PyGithub/PyGithub / testWithFirstPage

Method testWithFirstPage

tests/PaginatedList.py:398–443  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

396 # more custom per page tests in CompletableGithubObjectWithPaginatedProperty
397
398 def testWithFirstPage(self):
399 # fetching the commit also fetches the fist page of files
400 with self.captureRequests() as requests:
401 repo = self.g.get_repo("PyGithub/PyGithub", lazy=True)
402 commit = repo.get_commit("e359b83a04e8f34bedab0f2180169012d238a135", commit_files_per_page=3)
403 # repo is lazy, so this commit is also lazy, here we test with an eager (fetched) commit
404 commit.complete()
405 files = commit.files
406 self.assertListKeyEqual(
407 requests,
408 lambda r: r.url,
409 ["/repos/PyGithub/PyGithub/commits/e359b83a04e8f34bedab0f2180169012d238a135?page=1&per_page=3"],
410 )
411
412 # consuming the first page of files should not fire a request
413 with self.captureRequests() as requests:
414 self.assertEqual(files[0].filename, "github/GeneratedReleaseNotes.py")
415 self.assertEqual(files[1].filename, "github/Repository.py")
416 self.assertEqual(files[2].filename, "pyproject.toml")
417 self.assertEqual(len(requests), 0)
418
419 # consuming items of the second page fetches the second page
420 with self.captureRequests() as requests:
421 self.assertEqual(files[3].filename, "tests/ReplayData/Repository.testGenerateReleaseNotes.txt")
422 self.assertListKeyEqual(
423 requests,
424 lambda r: r.url,
425 ["/repositories/3544490/commits/e359b83a04e8f34bedab0f2180169012d238a135?page=2&per_page=3"],
426 )
427
428 # consuming further items of the second page does not fire a request
429 with self.captureRequests() as requests:
430 self.assertEqual(
431 files[4].filename, "tests/ReplayData/Repository.testGenerateReleaseNotesWithAllArguments.txt"
432 )
433 self.assertEqual(files[5].filename, "tests/Repository.py")
434 self.assertEqual(len(requests), 0)
435
436 # consuming items of the last page fetches the that page
437 with self.captureRequests() as requests:
438 self.assertEqual(files[6].filename, "tests/test_release_notes.yml")
439 self.assertListKeyEqual(
440 requests,
441 lambda r: r.url,
442 ["/repositories/3544490/commits/e359b83a04e8f34bedab0f2180169012d238a135?page=3&per_page=3"],
443 )
444
445 def testWithFirstSinglePage(self):
446 # fetching the commit also fetches the fist page of files

Callers

nothing calls this directly

Calls 5

captureRequestsMethod · 0.80
get_commitMethod · 0.80
completeMethod · 0.80
assertListKeyEqualMethod · 0.80
get_repoMethod · 0.45

Tested by

no test coverage detected