Diff
Modified: trunk/Tools/ChangeLog (289242 => 289243)
--- trunk/Tools/ChangeLog 2022-02-07 23:03:37 UTC (rev 289242)
+++ trunk/Tools/ChangeLog 2022-02-07 23:05:04 UTC (rev 289243)
@@ -1,3 +1,55 @@
+2022-02-07 Jonathan Bedard <[email protected]>
+
+ [webkitbugspy] Assign and close issues
+ https://bugs.webkit.org/show_bug.cgi?id=235835
+ <rdar://problem/88203672>
+
+ Reviewed by Dewei Zhu.
+
+ Allow webkitbugspy to edit the assignee and open or close issues.
+
+ * Scripts/libraries/webkitbugspy/setup.py: Bump version.
+ * Scripts/libraries/webkitbugspy/webkitbugspy/__init__.py: Ditto.
+ * Scripts/libraries/webkitbugspy/webkitbugspy/bugzilla.py:
+ (Tracker.set): Send a put request to modify assignee or bug state.
+ * Scripts/libraries/webkitbugspy/webkitbugspy/github.py:
+ (Tracker.set): Send a patch request to modify assignee or bug state.
+ * Scripts/libraries/webkitbugspy/webkitbugspy/issue.py:
+ (Issue.open): Re-open a closed issue, provide an optional reason.
+ (Issue.close): Close an open issue, with an optional reason.
+ (Issue.assign): Assign issue to the provided user, along with an optional reason.
+ * Scripts/libraries/webkitbugspy/webkitbugspy/mocks/bugzilla.py:
+ (Bugzilla._issue): Edit mocked representation of an issue.
+ (Bugzilla.request): Handle put request modifying issue.
+ * Scripts/libraries/webkitbugspy/webkitbugspy/mocks/github.py:
+ (GitHub._issue): Edit mocked representation of an issue.
+ (GitHub.request): Handle patch request modifying issue.
+ * Scripts/libraries/webkitbugspy/webkitbugspy/mocks/radar.py:
+ (RadarModel.Person.__init__): Accept dictionary.
+ (RadarModel.__init__): Correct 'state' values, mock radar parameters.
+ (RadarModel.commit_changes): Modify assignee and state.
+ * Scripts/libraries/webkitbugspy/webkitbugspy/radar.py:
+ (Priority): Add radar priority integers.
+ (Tracker.set): Modify assignee and state.
+ * Scripts/libraries/webkitbugspy/webkitbugspy/tests/bugzilla_unittest.py:
+ (TestBugzilla.test_assign):
+ (TestBugzilla.test_assign_why):
+ (TestBugzilla.test_state):
+ (TestBugzilla.test_state_why):
+ * Scripts/libraries/webkitbugspy/webkitbugspy/tests/github_unittest.py:
+ (TestGitHub.test_assign):
+ (TestGitHub.test_assign_why):
+ (TestGitHub.test_state):
+ (TestGitHub.test_state_why):
+ * Scripts/libraries/webkitbugspy/webkitbugspy/tests/radar_unittest.py:
+ (TestRadar.test_assign):
+ (TestRadar.test_assign_why):
+ (TestRadar.test_state):
+ (TestRadar.test_state_why):
+ * Scripts/libraries/webkitbugspy/webkitbugspy/tracker.py:
+ (Tracker.set): Generic API for Issues to modify their representation in their
+ respective tracker.
+
2022-02-07 Simon Fraser <[email protected]>
Tidy up some ImageBuffer-related classes
Modified: trunk/Tools/Scripts/libraries/webkitbugspy/setup.py (289242 => 289243)
--- trunk/Tools/Scripts/libraries/webkitbugspy/setup.py 2022-02-07 23:03:37 UTC (rev 289242)
+++ trunk/Tools/Scripts/libraries/webkitbugspy/setup.py 2022-02-07 23:05:04 UTC (rev 289243)
@@ -30,7 +30,7 @@
setup(
name='webkitbugspy',
- version='0.1.1',
+ version='0.2.0',
description='Library containing a shared API for various bug trackers.',
long_description=readme(),
classifiers=[
Modified: trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/__init__.py (289242 => 289243)
--- trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/__init__.py 2022-02-07 23:03:37 UTC (rev 289242)
+++ trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/__init__.py 2022-02-07 23:05:04 UTC (rev 289243)
@@ -46,7 +46,7 @@
"Please install webkitcorepy with `pip install webkitcorepy --extra-index-url <package index URL>`"
)
-version = Version(0, 1, 1)
+version = Version(0, 2, 0)
from .user import User
from .issue import Issue
Modified: trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/bugzilla.py (289242 => 289243)
--- trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/bugzilla.py 2022-02-07 23:03:37 UTC (rev 289242)
+++ trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/bugzilla.py 2022-02-07 23:05:04 UTC (rev 289243)
@@ -31,6 +31,7 @@
from .tracker import Tracker as GenericTracker
from datetime import datetime
+from webkitbugspy import User
class Tracker(GenericTracker):
@@ -212,6 +213,46 @@
return issue
+ def set(self, issue, assignee=None, opened=None, why=None, **properties):
+ update_dict = dict()
+
+ if properties:
+ raise TypeError("'{}' is an invalid property".format(list(properties.keys())[0]))
+
+ if assignee:
+ if not isinstance(assignee, User):
+ raise TypeError("Must assign to '{}', not '{}'".format(User, type(assignee)))
+ issue._assignee = self.user(name=assignee.name, username=assignee.username, email=assignee.email)
+ update_dict['assigned_to'] = issue._assignee.username
+
+ if opened is not None:
+ issue._opened = bool(opened)
+ if issue._opened:
+ update_dict['status'] = 'REOPENED'
+ why = why or 'Reopening bug'
+ else:
+ update_dict['status'] = 'RESOLVED'
+ update_dict['resolution'] = 'FIXED'
+
+ if why is not None:
+ update_dict['comment'] = dict(body=why)
+
+ if update_dict:
+ update_dict['ids'] = [issue.id]
+ response = requests.put(
+ '{}/rest/bug/{}{}'.format(self.url, issue.id, self._login_arguments(required=True)),
+ json=update_dict,
+ )
+ if response.status_code // 100 != 2:
+ if assignee:
+ issue._assignee = None
+ if opened is not None:
+ issue._opened = None
+ sys.stderr.write("Failed to modify '{}'\n".format(issue))
+ return None
+
+ return issue
+
def add_comment(self, issue, text):
response = requests.post(
'{}/rest/bug/{}/comment{}'.format(self.url, issue.id, self._login_arguments(required=True)),
Modified: trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/github.py (289242 => 289243)
--- trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/github.py 2022-02-07 23:03:37 UTC (rev 289242)
+++ trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/github.py 2022-02-07 23:05:04 UTC (rev 289243)
@@ -32,6 +32,7 @@
from datetime import datetime
from requests.auth import HTTPBasicAuth
+from webkitbugspy import User
class Tracker(GenericTracker):
@@ -267,6 +268,44 @@
return issue
+ def set(self, issue, assignee=None, opened=None, why=None, **properties):
+ update_dict = dict()
+
+ if properties:
+ raise TypeError("'{}' is an invalid property".format(list(properties.keys())[0]))
+
+ if assignee:
+ if not isinstance(assignee, User):
+ raise TypeError("Must assign to '{}', not '{}'".format(User, type(assignee)))
+ issue._assignee = self.user(name=assignee.name, username=assignee.username, email=assignee.email)
+ update_dict['assignees'] = [issue._assignee.username]
+
+ if opened is not None:
+ issue._opened = bool(opened)
+ update_dict['state'] = 'open' if issue._opened else 'closed'
+
+ if update_dict:
+ update_dict['number'] = [issue.id]
+ response = requests.patch(
+ '{api_url}/repos/{owner}/{name}/issues/{id}'.format(
+ api_url=self.api_url,
+ owner=self.owner,
+ name=self.name,
+ id=issue.id,
+ ), auth=HTTPBasicAuth(*self.credentials(required=True)),
+ headers=dict(Accept='application/vnd.github.v3+json'),
+ json=update_dict,
+ )
+ if response.status_code // 100 != 2:
+ if assignee:
+ issue._assignee = None
+ if opened is not None:
+ issue._opened = None
+ sys.stderr.write("Failed to modify '{}'\n".format(issue))
+ return None
+
+ return self.add_comment(issue, why) if why else issue
+
def add_comment(self, issue, text):
response = requests.post(
'{api_url}/repos/{owner}/{name}/issues/{id}/comments'.format(
Modified: trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/issue.py (289242 => 289243)
--- trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/issue.py 2022-02-07 23:03:37 UTC (rev 289242)
+++ trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/issue.py 2022-02-07 23:05:04 UTC (rev 289243)
@@ -108,6 +108,16 @@
self.tracker.populate(self, 'opened')
return self._opened
+ def open(self, why=None):
+ if self.opened:
+ return False
+ return bool(self.tracker.set(self, opened=True, why=why))
+
+ def close(self, why=None):
+ if not self.opened:
+ return False
+ return bool(self.tracker.set(self, opened=False, why=why))
+
@property
def assignee(self):
if self._assignee is None:
@@ -114,6 +124,10 @@
self.tracker.populate(self, 'assignee')
return self._assignee
+ def assign(self, assignee, why=None):
+ self.tracker.set(self, assignee=assignee, why=why)
+ return self.assignee
+
@property
def watchers(self):
if self._watchers is None:
Modified: trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/mocks/bugzilla.py (289242 => 289243)
--- trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/mocks/bugzilla.py 2022-02-07 23:03:37 UTC (rev 289242)
+++ trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/mocks/bugzilla.py 2022-02-07 23:05:04 UTC (rev 289243)
@@ -98,7 +98,9 @@
return None
return self.users.get(match.group('login'))
- def _issue(self, url, id):
+ def _issue(self, url, id, credentials=None, data=""
+ user = self._user_for_credentials(credentials)
+
if id not in self.issues:
return mocks.Response(
url=""
@@ -111,12 +113,37 @@
)),
)
issue = self.issues[id]
+ if data:
+ if not user:
+ return mocks.Response(status_code=401, url=""
+
+ if self.users.get(data.get('assigned_to')):
+ issue['assignee'] = self.users[data['assigned_to']]
+ if data.get('status'):
+ if not issue['opened'] and data['status'] != 'REOPENED' and not data.get('comment'):
+ return mocks.Response(
+ url=""
+ headers={'Content-Type': 'text/json'},
+ status_code=400,
+ text=json.dumps(dict(
+ code=32000,
+ error=True,
+ message="You have to specify a comment when changing the Status of a bug from RESOLVED to REOPENED.",
+ )),
+ )
+ issue['opened'] = data['status'] == 'REOPENED'
+ if data.get('comment'):
+ issue['comments'].append(
+ Issue.Comment(user=user, timestamp=int(time.time()), content=data['comment']['body']),
+ )
+
return mocks.Response.fromJson(dict(
bugs=[dict(
id=id,
summary=issue['title'],
creation_time=self.time_string(issue['timestamp']),
- status='RESOLVED' if issue['opened'] else 'FIXED',
+ status='REOPENED' if issue['opened'] else 'RESOLVED',
+ resolution='' if issue['opened'] else 'FIXED',
creator=self.users[issue['creator'].name].username,
creator_detail=dict(
email=issue['creator'].email,
@@ -231,6 +258,8 @@
match = re.match(r'{}/rest/bug/(?P<id>\d+)(?P<credentials>\?login=\S+\&password=\S+)?$'.format(self.hosts[0]), stripped_url)
if match and method == 'GET':
return self._issue(url, int(match.group('id')))
+ if match and method == 'PUT':
+ return self._issue(url, int(match.group('id')), match.group('credentials'), data=""
match = re.match(r'{}/rest/bug/(?P<id>\d+)\?(?P<credentials>login=\S+\&password=\S+\&)?include_fields=see_also$'.format(self.hosts[0]), stripped_url)
if match and method == 'GET':
Modified: trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/mocks/github.py (289242 => 289243)
--- trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/mocks/github.py 2022-02-07 23:03:37 UTC (rev 289242)
+++ trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/mocks/github.py 2022-02-07 23:05:04 UTC (rev 289243)
@@ -78,7 +78,7 @@
email=user.email,
), url=""
- def _issue(self, url, id):
+ def _issue(self, url, id, data=""
if id not in self.issues:
return mocks.Response(
url=""
@@ -87,6 +87,14 @@
text=json.dumps(dict(message="Not Found")),
)
issue = self.issues[id]
+ if data:
+ if self.users.get(data.get('assignees', [None])[0]):
+ issue['assignee'] = self.users[data['assignees'][0]]
+ if data.get('state') == 'opened':
+ issue['opened'] = True
+ if data.get('state') == 'closed':
+ issue['opened'] = False
+
return mocks.Response.fromJson(dict(
title=issue['title'],
body=issue['description'],
@@ -171,8 +179,8 @@
return self._user(url, match.group('username'))
match = re.match(r'{}/issues/(?P<id>\d+)$'.format(self.api_host), stripped_url)
- if match and method == 'GET':
- return self._issue(url, int(match.group('id')))
+ if match and method in ('GET', 'PATCH'):
+ return self._issue(url, int(match.group('id')), data="" if method == 'PATCH' else None)
match = re.match(r'{}/issues/(?P<id>\d+)/comments$'.format(self.api_host), stripped_url)
if match and method == 'GET':
Modified: trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/mocks/radar.py (289242 => 289243)
--- trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/mocks/radar.py 2022-02-07 23:03:37 UTC (rev 289242)
+++ trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/mocks/radar.py 2022-02-07 23:05:04 UTC (rev 289243)
@@ -64,10 +64,16 @@
class RadarModel(object):
class Person(object):
def __init__(self, user):
- self.firstName = user.name.split(' ', 1)[0]
- self.lastName = user.name.split(' ', 1)[1]
- self.email = user.email
- self.dsid = user.username
+ if isinstance(user, dict):
+ self.firstName = user.get('firstName')
+ self.lastName = user.get('lastName')
+ self.email = user.get('email')
+ self.dsid = user.get('dsid')
+ else:
+ self.firstName = user.name.split(' ', 1)[0]
+ self.lastName = user.name.split(' ', 1)[1]
+ self.email = user.email
+ self.dsid = user.username
class CCMembership(object):
def __init__(self, user):
@@ -116,7 +122,11 @@
self.createdAt = datetime.utcfromtimestamp(issue['timestamp'] - timedelta(hours=7).seconds)
self.assignee = self.Person(Radar.transform_user(issue['assignee']))
self.description = self.CollectionProperty(self, self.DescriptionEntry(issue['description']))
- self.state = 'Investigate' if issue['opened'] else 'Verify'
+ self.state = 'Analyze' if issue['opened'] else 'Verify'
+ self.substate = 'Investigate' if issue['opened'] else None
+ self.milestone = '?'
+ self.priority = 2
+ self.resolution = 'Unresolved' if issue['opened'] else 'Software Changed'
self.originator = self.Person(Radar.transform_user(issue['creator']))
self.diagnosis = self.CollectionProperty(self, *[
Radar.DiagnosisEntry(
@@ -143,6 +153,8 @@
content=entry.text,
) for entry in self.diagnosis.items()
]
+ self.client.parent.issues[self.id]['assignee'] = self.client.parent.users[self.assignee.dsid]
+ self.client.parent.issues[self.id]['opened'] = self.state not in ('Verify', 'Closed')
class RadarClient(object):
@@ -160,6 +172,8 @@
class Radar(Base, ContextStack):
top = None
+ Person = RadarModel.Person
+
class AuthenticationStrategySystemAccount(object):
def __init__(self, username, __, ___, ____):
self._username = username
Modified: trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/radar.py (289242 => 289243)
--- trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/radar.py 2022-02-07 23:03:37 UTC (rev 289242)
+++ trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/radar.py 2022-02-07 23:05:04 UTC (rev 289243)
@@ -29,6 +29,14 @@
from webkitbugspy import Issue, Tracker as GenericTracker, User, name as library_name, version as library_version
+class Priority(object):
+ SHOW_STOPPER = 1
+ EXPECTED = 2
+ IMPORTANT = 3
+ NICE_TO_HAVE = 4
+ NOT_SET = 5
+
+
class Tracker(GenericTracker):
RES = [
re.compile(r'<?rdar://problem/(?P<id>\d+)>?'),
@@ -193,6 +201,45 @@
return issue
+ def set(self, issue, assignee=None, opened=None, why=None, **properties):
+ if not self.client or not self.library:
+ sys.stderr.write('radarclient inaccessible on this machine\n')
+ return None
+ if properties:
+ raise TypeError("'{}' is an invalid property".format(list(properties.keys())[0]))
+
+ radar = self.client.radar_for_id(issue.id)
+ if not radar:
+ sys.stderr.write("Failed to fetch '{}'\n".format(issue.link))
+ return None
+
+ did_change = False
+
+ if assignee:
+ if not isinstance(assignee, User):
+ raise TypeError("Must assign to '{}', not '{}'".format(User, type(assignee)))
+ issue._assignee = self.user(name=assignee.name, username=assignee.username, email=assignee.email)
+ radar.assignee = self.library.Person({'dsid': int(issue._assignee.username)})
+ did_change = True
+
+ if opened is not None:
+ issue._opened = bool(opened)
+ if issue._opened:
+ radar.state = 'Analyze'
+ if radar.milestone is None or radar.priority == Priority.NOT_SET:
+ radar.substate = 'Screen'
+ else:
+ radar.substate = 'Investigate'
+ radar.resolution = 'Unresolved'
+ else:
+ radar.state = 'Verify'
+ radar.resolution = 'Software Changed'
+ did_change = True
+
+ if did_change:
+ radar.commit_changes()
+ return self.add_comment(issue, why) if why else issue
+
def add_comment(self, issue, text):
if not self.client or not self.library:
sys.stderr.write('radarclient inaccessible on this machine\n')
Modified: trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/tests/bugzilla_unittest.py (289242 => 289243)
--- trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/tests/bugzilla_unittest.py 2022-02-07 23:03:37 UTC (rev 289242)
+++ trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/tests/bugzilla_unittest.py 2022-02-07 23:05:04 UTC (rev 289243)
@@ -174,8 +174,8 @@
def test_add_comment(self):
with mocks.Bugzilla(self.URL.split('://')[1], issues=mocks.ISSUES, environment=wkmocks.Environment(
- BUGS_EXAMPLE_COM_USERNAME='[email protected]',
- BUGS_EXAMPLE_COM_PASSWORD='password',
+ BUGS_EXAMPLE_COM_USERNAME='[email protected]',
+ BUGS_EXAMPLE_COM_PASSWORD='password',
)):
issue = bugzilla.Tracker(self.URL).issue(1)
self.assertEqual(len(issue.comments), 2)
@@ -189,3 +189,76 @@
self.assertEqual(len(issue.comments), 3)
self.assertEqual(len(bugzilla.Tracker(self.URL).issue(1).comments), 3)
+
+ def test_assign(self):
+ with mocks.Bugzilla(self.URL.split('://')[1], issues=mocks.ISSUES, environment=wkmocks.Environment(
+ BUGS_EXAMPLE_COM_USERNAME='[email protected]',
+ BUGS_EXAMPLE_COM_PASSWORD='password',
+ )):
+ issue = bugzilla.Tracker(self.URL).issue(1)
+ self.assertEqual(
+ User.Encoder().default(issue.assignee),
+ dict(name='Tim Contributor', username='[email protected]', emails=['[email protected]']),
+ )
+ issue.assign(bugzilla.Tracker(self.URL).me())
+ self.assertEqual(
+ User.Encoder().default(issue.assignee),
+ dict(name='Felix Filer', username='[email protected]', emails=['[email protected]']),
+ )
+
+ issue = bugzilla.Tracker(self.URL).issue(1)
+ self.assertEqual(
+ User.Encoder().default(issue.assignee),
+ dict(name='Felix Filer', username='[email protected]', emails=['[email protected]']),
+ )
+
+ def test_assign_why(self):
+ with mocks.Bugzilla(self.URL.split('://')[1], issues=mocks.ISSUES, environment=wkmocks.Environment(
+ BUGS_EXAMPLE_COM_USERNAME='[email protected]',
+ BUGS_EXAMPLE_COM_PASSWORD='password',
+ )):
+ issue = bugzilla.Tracker(self.URL).issue(1)
+ self.assertEqual(
+ User.Encoder().default(issue.assignee),
+ dict(name='Tim Contributor', username='[email protected]', emails=['[email protected]']),
+ )
+ issue.assign(bugzilla.Tracker(self.URL).me(), why='Let me provide a better reproduction')
+ self.assertEqual(
+ User.Encoder().default(issue.assignee),
+ dict(name='Felix Filer', username='[email protected]', emails=['[email protected]']),
+ )
+ self.assertEqual(issue.comments[-1].content, 'Let me provide a better reproduction')
+
+ def test_state(self):
+ with mocks.Bugzilla(self.URL.split('://')[1], issues=mocks.ISSUES, environment=wkmocks.Environment(
+ BUGS_EXAMPLE_COM_USERNAME='[email protected]',
+ BUGS_EXAMPLE_COM_PASSWORD='password',
+ )):
+ issue = bugzilla.Tracker(self.URL).issue(1)
+ self.assertTrue(issue.opened)
+ self.assertFalse(issue.open())
+ self.assertTrue(issue.close())
+ self.assertFalse(issue.opened)
+
+ issue = bugzilla.Tracker(self.URL).issue(1)
+ self.assertFalse(issue.opened)
+ self.assertFalse(issue.close())
+ self.assertTrue(issue.open())
+ self.assertTrue(issue.opened)
+
+ def test_state_why(self):
+ with mocks.Bugzilla(self.URL.split('://')[1], issues=mocks.ISSUES, environment=wkmocks.Environment(
+ BUGS_EXAMPLE_COM_USERNAME='[email protected]',
+ BUGS_EXAMPLE_COM_PASSWORD='password',
+ )):
+ issue = bugzilla.Tracker(self.URL).issue(1)
+ self.assertTrue(issue.opened)
+ self.assertTrue(issue.close(why='Fixed in 1234@main'))
+ self.assertFalse(issue.opened)
+ self.assertEqual(issue.comments[-1].content, 'Fixed in 1234@main')
+
+ issue = bugzilla.Tracker(self.URL).issue(1)
+ self.assertFalse(issue.opened)
+ self.assertTrue(issue.open(why='Need to revert, fix broke the build'))
+ self.assertTrue(issue.opened)
+ self.assertEqual(issue.comments[-1].content, 'Need to revert, fix broke the build')
Modified: trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/tests/github_unittest.py (289242 => 289243)
--- trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/tests/github_unittest.py 2022-02-07 23:03:37 UTC (rev 289242)
+++ trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/tests/github_unittest.py 2022-02-07 23:05:04 UTC (rev 289243)
@@ -185,3 +185,76 @@
self.assertEqual(len(issue.comments), 3)
self.assertEqual(len(github.Tracker(self.URL).issue(1).comments), 3)
+
+ def test_assign(self):
+ with mocks.GitHub(self.URL.split('://')[1], issues=mocks.ISSUES, environment=wkmocks.Environment(
+ GITHUB_EXAMPLE_COM_USERNAME='ffiler',
+ GITHUB_EXAMPLE_COM_TOKEN='token',
+ )):
+ issue = github.Tracker(self.URL).issue(1)
+ self.assertEqual(
+ User.Encoder().default(issue.assignee),
+ dict(name='Tim Contributor', username='tcontributor', emails=['[email protected]']),
+ )
+ issue.assign(github.Tracker(self.URL).me())
+ self.assertEqual(
+ User.Encoder().default(issue.assignee),
+ dict(name='Felix Filer', username='ffiler', emails=['[email protected]']),
+ )
+
+ issue = github.Tracker(self.URL).issue(1)
+ self.assertEqual(
+ User.Encoder().default(issue.assignee),
+ dict(name='Felix Filer', username='ffiler', emails=['[email protected]']),
+ )
+
+ def test_assign_why(self):
+ with mocks.GitHub(self.URL.split('://')[1], issues=mocks.ISSUES, environment=wkmocks.Environment(
+ GITHUB_EXAMPLE_COM_USERNAME='ffiler',
+ GITHUB_EXAMPLE_COM_TOKEN='token',
+ )):
+ issue = github.Tracker(self.URL).issue(1)
+ self.assertEqual(
+ User.Encoder().default(issue.assignee),
+ dict(name='Tim Contributor', username='tcontributor', emails=['[email protected]']),
+ )
+ issue.assign(github.Tracker(self.URL).me(), why='Let me provide a better reproduction')
+ self.assertEqual(
+ User.Encoder().default(issue.assignee),
+ dict(name='Felix Filer', username='ffiler', emails=['[email protected]']),
+ )
+ self.assertEqual(issue.comments[-1].content, 'Let me provide a better reproduction')
+
+ def test_state(self):
+ with mocks.GitHub(self.URL.split('://')[1], issues=mocks.ISSUES, environment=wkmocks.Environment(
+ GITHUB_EXAMPLE_COM_USERNAME='tcontributor',
+ GITHUB_EXAMPLE_COM_TOKEN='token',
+ )):
+ issue = github.Tracker(self.URL).issue(1)
+ self.assertTrue(issue.opened)
+ self.assertFalse(issue.open())
+ self.assertTrue(issue.close())
+ self.assertFalse(issue.opened)
+
+ issue = github.Tracker(self.URL).issue(1)
+ self.assertFalse(issue.opened)
+ self.assertFalse(issue.close())
+ self.assertTrue(issue.open())
+ self.assertTrue(issue.opened)
+
+ def test_state_why(self):
+ with mocks.GitHub(self.URL.split('://')[1], issues=mocks.ISSUES, environment=wkmocks.Environment(
+ GITHUB_EXAMPLE_COM_USERNAME='tcontributor',
+ GITHUB_EXAMPLE_COM_TOKEN='token',
+ )):
+ issue = github.Tracker(self.URL).issue(1)
+ self.assertTrue(issue.opened)
+ self.assertTrue(issue.close(why='Fixed in 1234@main'))
+ self.assertFalse(issue.opened)
+ self.assertEqual(issue.comments[-1].content, 'Fixed in 1234@main')
+
+ issue = github.Tracker(self.URL).issue(1)
+ self.assertFalse(issue.opened)
+ self.assertTrue(issue.open(why='Need to revert, fix broke the build'))
+ self.assertTrue(issue.opened)
+ self.assertEqual(issue.comments[-1].content, 'Need to revert, fix broke the build')
Modified: trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/tests/radar_unittest.py (289242 => 289243)
--- trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/tests/radar_unittest.py 2022-02-07 23:03:37 UTC (rev 289242)
+++ trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/tests/radar_unittest.py 2022-02-07 23:05:04 UTC (rev 289243)
@@ -163,3 +163,64 @@
self.assertEqual(len(issue.comments), 3)
self.assertEqual(len(radar.Tracker().issue(1).comments), 3)
+
+ def test_assign(self):
+ with wkmocks.Environment(RADAR_USERNAME='ffiler'), mocks.Radar(issues=mocks.ISSUES):
+ issue = radar.Tracker().issue(1)
+ self.assertEqual(
+ User.Encoder().default(issue.assignee),
+ dict(name='Tim Contributor', username=504, emails=['[email protected]']),
+ )
+ issue.assign(radar.Tracker().me())
+ self.assertEqual(
+ User.Encoder().default(issue.assignee),
+ dict(name='Felix Filer', username=809, emails=['[email protected]']),
+ )
+
+ issue = radar.Tracker().issue(1)
+ self.assertEqual(
+ User.Encoder().default(issue.assignee),
+ dict(name='Felix Filer', username=809, emails=['[email protected]']),
+ )
+
+ def test_assign_why(self):
+ with wkmocks.Environment(RADAR_USERNAME='ffiler'), mocks.Radar(issues=mocks.ISSUES):
+ issue = radar.Tracker().issue(1)
+ self.assertEqual(
+ User.Encoder().default(issue.assignee),
+ dict(name='Tim Contributor', username=504, emails=['[email protected]']),
+ )
+ issue.assign(radar.Tracker().me(), why='Let me provide a better reproduction')
+ self.assertEqual(
+ User.Encoder().default(issue.assignee),
+ dict(name='Felix Filer', username=809, emails=['[email protected]']),
+ )
+ self.assertEqual(issue.comments[-1].content, 'Let me provide a better reproduction')
+
+ def test_state(self):
+ with wkmocks.Environment(RADAR_USERNAME='tcontributor'), mocks.Radar(issues=mocks.ISSUES):
+ issue = radar.Tracker().issue(1)
+ self.assertTrue(issue.opened)
+ self.assertFalse(issue.open())
+ self.assertTrue(issue.close())
+ self.assertFalse(issue.opened)
+
+ issue = radar.Tracker().issue(1)
+ self.assertFalse(issue.opened)
+ self.assertFalse(issue.close())
+ self.assertTrue(issue.open())
+ self.assertTrue(issue.opened)
+
+ def test_state_why(self):
+ with wkmocks.Environment(RADAR_USERNAME='tcontributor'), mocks.Radar(issues=mocks.ISSUES):
+ issue = radar.Tracker().issue(1)
+ self.assertTrue(issue.opened)
+ self.assertTrue(issue.close(why='Fixed in 1234@main'))
+ self.assertFalse(issue.opened)
+ self.assertEqual(issue.comments[-1].content, 'Fixed in 1234@main')
+
+ issue = radar.Tracker().issue(1)
+ self.assertFalse(issue.opened)
+ self.assertTrue(issue.open(why='Need to revert, fix broke the build'))
+ self.assertTrue(issue.opened)
+ self.assertEqual(issue.comments[-1].content, 'Need to revert, fix broke the build')
Modified: trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/tracker.py (289242 => 289243)
--- trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/tracker.py 2022-02-07 23:03:37 UTC (rev 289242)
+++ trunk/Tools/Scripts/libraries/webkitbugspy/webkitbugspy/tracker.py 2022-02-07 23:05:04 UTC (rev 289243)
@@ -107,5 +107,8 @@
def populate(self, issue, member=None):
raise NotImplementedError()
+ def set(self, issue, **properties):
+ raise NotImplementedError()
+
def add_comment(self, issue, text):
raise NotImplementedError()
Modified: trunk/Tools/Scripts/webkitpy/__init__.py (289242 => 289243)
--- trunk/Tools/Scripts/webkitpy/__init__.py 2022-02-07 23:03:37 UTC (rev 289242)
+++ trunk/Tools/Scripts/webkitpy/__init__.py 2022-02-07 23:05:04 UTC (rev 289243)
@@ -86,5 +86,6 @@
AutoInstall.register(Package('webkitflaskpy', Version(0, 1, 1)), local=True)
AutoInstall.register(Package('webkitscmpy', Version(0, 12, 5)), local=True)
+AutoInstall.register(Package('webkitbugspy', Version(0, 1, 0)), local=True)
import webkitscmpy