Update records if user name changed in default data

Closes bug 1214307

Change-Id: I809c320a186ff0c7408f67ad782c6ab3f12c5b13
This commit is contained in:
Ilya Shakhat 2013-08-20 13:40:35 +04:00
parent 5957b954bd
commit ed51e565bb
3 changed files with 42 additions and 2 deletions

View File

@ -132,8 +132,11 @@ class Gerrit(Rcs):
# poll open reviews from last_id down to bottom
LOG.debug('Poll open reviews')
start_id = None
if last_id:
start_id = last_id + 1 # include the last review into query
for review in self._poll_reviews(project_organization, module, branch,
start_id=last_id + 1, is_open=True):
start_id=start_id, is_open=True):
yield review
self.client.close()

View File

@ -235,11 +235,13 @@ class RecordProcessor(object):
company_name = record['company_name']
user_id = record['user_id']
author_name = record['author_name']
self._update_record_and_user(record)
if ((record['company_name'] != company_name) or
(record['user_id'] != user_id)):
(record['user_id'] != user_id) or
(record['author_name'] != author_name)):
need_update = True
if record['primary_key'] in release_index:

View File

@ -255,3 +255,38 @@ class TestRecordProcessor(testtools.TestCase):
self.assertEquals(0, self.read_json.called)
self.assertEquals('*independent', commit['company_name'])
self.assertEquals(None, commit['launchpad_id'])
def _generate_record_commit(self):
yield {'commit_id': u'0afdc64bfd041b03943ceda7849c4443940b6053',
'lines_added': 9,
'module': u'stackalytics',
'record_type': 'commit',
'message': u'Closes bug 1212953\n\nChange-Id: '
u'I33f0f37b6460dc494abf2520dc109c9893ace9e6\n',
'subject': u'Fixed affiliation of Edgar and Sumit',
'loc': 10,
'user_id': u'john_doe',
'primary_key': u'0afdc64bfd041b03943ceda7849c4443940b6053',
'author_email': u'jdoe@super.no',
'company_name': u'SuperCompany',
'record_id': 6,
'lines_deleted': 1,
'week': 2275,
'blueprint_id': None,
'bug_id': u'1212953',
'files_changed': 1,
'author_name': u'John Doe',
'date': 1376737923,
'launchpad_id': u'john_doe',
'branches': set([u'master']),
'change_id': u'I33f0f37b6460dc494abf2520dc109c9893ace9e6',
'release': u'havana'}
def test_update_record_no_changes(self):
commit_generator = self._generate_record_commit()
release_index = {'0afdc64bfd041b03943ceda7849c4443940b6053': 'havana'}
updated = list(self.commit_processor.update(commit_generator,
release_index))
self.assertEquals(0, len(updated))