(self)
| 443 | ) |
| 444 | |
| 445 | def testWithFirstSinglePage(self): |
| 446 | # fetching the commit also fetches the fist page of files |
| 447 | with self.captureRequests() as requests: |
| 448 | repo = self.g.get_repo("PyGithub/PyGithub", lazy=True) |
| 449 | commit = repo.get_commit("f5f9756a1dd52a53820cc54927abb34725377987", commit_files_per_page=3) |
| 450 | # repo is lazy, so this commit is also lazy, here we test with an eager (fetched) commit |
| 451 | commit.complete() |
| 452 | files = commit.files |
| 453 | # with a single page we by now know the total count without firing a request |
| 454 | self.assertEqual(files.totalCount, 3) |
| 455 | self.assertListKeyEqual( |
| 456 | requests, |
| 457 | lambda r: r.url, |
| 458 | ["/repos/PyGithub/PyGithub/commits/f5f9756a1dd52a53820cc54927abb34725377987?page=1&per_page=3"], |
| 459 | ) |
| 460 | |
| 461 | # consuming the first page of files should not fire a request |
| 462 | with self.captureRequests() as requests: |
| 463 | self.assertEqual(files[0].filename, "github/GithubApp.py") |
| 464 | self.assertEqual(files[1].filename, "github/GithubObject.py") |
| 465 | self.assertEqual(files[2].filename, "tests/GithubObject.py") |
| 466 | self.assertEqual(len(requests), 0) |
| 467 | |
| 468 | def testReversedWithFirstPage(self): |
| 469 | # this is all lazy, no requests fired |
nothing calls this directly
no test coverage detected