Browse Source

Gerrit approval records have a 'by' field

We need to look one level deeper.

Change-Id: I81dbc316ded86739fd7d5413beb7a51a4e57e4f5
changes/25/69025/2
James E. Blair 8 years ago
parent
commit
64ff4ef301
  1. 8
      tests/test_scheduler.py
  2. 5
      zuul/model.py

8
tests/test_scheduler.py

@ -221,11 +221,13 @@ class FakeChange(object):
approval = {'description': self.categories[category][0],
'type': category,
'value': str(value),
'username': username,
'email': username + '@example.com',
'by': {
'username': username,
'email': username + '@example.com',
},
'grantedOn': int(granted_on)}
for i, x in enumerate(self.patchsets[-1]['approvals'][:]):
if x['username'] == username and x['type'] == category:
if x['by']['username'] == username and x['type'] == category:
del self.patchsets[-1]['approvals'][i]
self.patchsets[-1]['approvals'].append(approval)
event = {'approvals': [approval],

5
zuul/model.py

@ -1023,12 +1023,13 @@ class EventFilter(object):
matches_approval = False
for approval in change.approvals:
found_approval = True
by = approval.get('by', {})
for k, v in rapproval.items():
if k == 'username':
if (approval['username'] != v):
if (by.get('username', '') != v):
found_approval = False
elif k == 'email-filter':
if (not v.search(approval['email'])):
if (not v.search(by.get('email', ''))):
found_approval = False
elif k == 'newer-than':
t = now - v

Loading…
Cancel
Save