Skip to content

Commit

Permalink
[webkitscmpy] Fix setting title in mock Bitbucket server
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=273884
rdar://127751416

Reviewed by Dewei Zhu.

* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/remote/bitbucket.py:
(BitBucket.request): Allow underdefined 'fromRef' and 'toRef'.
* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/pull_request_unittest.py:
(TestNetworkPullRequestGitHub.test_title):
(TestNetworkPullRequestBitBucket.test_title):

Canonical link: https://commits.webkit.org/278593@main
  • Loading branch information
JonWBedard committed May 9, 2024
1 parent a53feed commit 98c3511
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -353,9 +353,11 @@ def request(self, method, url, data=None, params=None, json=None, **kwargs):
return mocks.Response.fromJson({})
if method == 'PUT':
self.pull_requests[existing].update(json)
self.pull_requests[existing]['fromRef']['displayId'] = '/'.join(json['fromRef']['id'].split('/')[-2:])
self.pull_requests[existing]['fromRef']['latestCommit'] = json['fromRef']['latestCommit']
self.pull_requests[existing]['toRef']['displayId'] = '/'.join(json['toRef']['id'].split('/')[-2:])
if 'id' in json['fromRef']:
self.pull_requests[existing]['fromRef']['displayId'] = '/'.join(json['fromRef']['id'].split('/')[-2:])
if 'id' in json['toRef']:
self.pull_requests[existing]['toRef']['displayId'] = '/'.join(json['toRef']['id'].split('/')[-2:])
if len(split_url) < 11:
return mocks.Response.fromJson({key: value for key, value in self.pull_requests[existing].items() if key not in ('commit', 'activities')})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2064,6 +2064,15 @@ def test_get(self):
self.assertEqual(pr.base, 'main')
self.assertEqual(pr.draft, False)

def test_title(self):
with self.webserver():
pr = remote.GitHub(self.remote).pull_requests.get(1)
self.assertEqual(pr.title, 'Example Change')
pr.generator.update(pr, title='New Title')

pr = remote.GitHub(self.remote).pull_requests.get(1)
self.assertEqual(pr.title, 'New Title')

def test_reviewers(self):
with self.webserver():
pr = remote.GitHub(self.remote).pull_requests.get(1)
Expand Down Expand Up @@ -2360,6 +2369,15 @@ def test_get(self):
self.assertEqual(pr.base, 'main')
self.assertEqual(pr.draft, False)

def test_title(self):
with self.webserver():
pr = remote.BitBucket(self.remote).pull_requests.get(1)
self.assertEqual(pr.title, 'Example Change')
pr.generator.update(pr, title='New Title')

pr = remote.BitBucket(self.remote).pull_requests.get(1)
self.assertEqual(pr.title, 'New Title')

def test_reviewers(self):
with self.webserver():
pr = remote.BitBucket(self.remote).pull_requests.get(1)
Expand Down

0 comments on commit 98c3511

Please sign in to comment.