Skip to content

Commit 40beeb8

Browse files
Add regression test for Bitbucket commits paging (#1642)
Co-authored-by: n4p68vc6p9-hub <296603378+n4p68vc6p9-hub@users.noreply.github.com>
1 parent 5bafa78 commit 40beeb8

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

tests/test_bitbucket_cloud_oo.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,28 @@ def test_not_exists_project(self):
3939
def test_exists_repository(self):
4040
assert CLOUD.workspaces.get("TestWorkspace1").repositories.exists("testrepository1"), "Exists repository"
4141

42+
def test_repository_commits_each_uses_paged_commit_data(self, monkeypatch):
43+
repository = CLOUD.workspaces.get("TestWorkspace1").repositories.get("testrepository1")
44+
commits = repository.commits
45+
commit_data = {
46+
"type": "commit",
47+
"hash": "1fbd047cd99a",
48+
"message": "src created online with Bitbucket",
49+
}
50+
51+
monkeypatch.setattr(commits, "_get_paged", lambda *args, **kwargs: iter([commit_data]))
52+
53+
def fail_get(*args, **kwargs):
54+
raise AssertionError("repository commits should not be fetched again by hash")
55+
56+
monkeypatch.setattr("atlassian.bitbucket.base.BitbucketBase.get", fail_get)
57+
58+
commit = list(commits.each())[0]
59+
60+
assert isinstance(commit, Commit)
61+
assert commit.hash == "1fbd047cd99a"
62+
assert commit.message == "src created online with Bitbucket"
63+
4264
def test_not_exists_repository(self):
4365
assert not CLOUD.workspaces.get("TestWorkspace1").repositories.exists(
4466
"testrepository1xxx"

0 commit comments

Comments
 (0)