Process gerrit id case sensitively

Closes bug 1386124

Change-Id: I12c22f0b525d1b780a2a69c86aa4941c6fd21da4
This commit is contained in:
Ilya Shakhat 2014-12-26 13:29:49 +03:00
parent 3207279faf
commit 9c0598da06
2 changed files with 34 additions and 3 deletions

View File

@ -331,7 +331,7 @@ class RecordProcessor(object):
owner = record['owner']
review['primary_key'] = review['id']
review['gerrit_id'] = owner['username'].lower()
review['gerrit_id'] = owner['username']
review['author_name'] = owner['name']
if owner.get('email'):
review['author_email'] = owner['email'].lower()
@ -362,7 +362,7 @@ class RecordProcessor(object):
patch_record['number'] = patch['number']
patch_record['date'] = patch['createdOn']
uploader = patch['uploader']
patch_record['gerrit_id'] = uploader['username'].lower()
patch_record['gerrit_id'] = uploader['username']
patch_record['author_name'] = uploader['name']
if uploader.get('email'):
patch_record['author_email'] = uploader['email'].lower()
@ -383,7 +383,7 @@ class RecordProcessor(object):
mark['value'] = int(approval['value'])
mark['date'] = approval['grantedOn']
mark['primary_key'] = (review['id'] + str(mark['date']) + mark['type'])
mark['gerrit_id'] = reviewer['username'].lower()
mark['gerrit_id'] = reviewer['username']
mark['author_name'] = reviewer['name']
mark['author_email'] = reviewer['email'].lower()
mark['module'] = review['module']

View File

@ -389,6 +389,37 @@ class TestRecordProcessor(testtools.TestCase):
self.assertEqual('IBM', user['companies'][0]['company_name'])
self.assertEqual(None, user['launchpad_id'])
def test_process_review_new_user(self):
# User is known to LP, but new to us
# Should add new user and set company depending on email
record_processor_inst = self.make_record_processor(
companies=[{'company_name': 'IBM', 'domains': ['ibm.com']}],
lp_info={'johndoe@ibm.com':
{'name': 'john_doe', 'display_name': 'John Doe'}})
processed_review = list(record_processor_inst.process([
{'record_type': 'review',
'id': 'I1045730e47e9e6ad31fcdfbaefdad77e2f3b2c3e',
'subject': 'Fix AttributeError in Keypair._add_details()',
'owner': {'name': 'John Doe',
'email': 'johndoe@ibm.com',
'username': 'John_Doe'},
'createdOn': 1379404951,
'module': 'nova', 'branch': 'master'}
]))[0]
expected_review = {
'user_id': 'john_doe',
'author_email': 'johndoe@ibm.com',
'author_name': 'John Doe',
'company_name': 'IBM',
}
self.assertRecordsMatch(expected_review, processed_review)
user = user_processor.load_user(
record_processor_inst.runtime_storage_inst, user_id='john_doe')
self.assertEqual('John_Doe', user['gerrit_id'])
def generate_bugs(self, assignee=None, date_fix_committed=None,
status='Confirmed'):
yield {