Remove duplicates from default_data.json

Also added test to prevent dups in the future

Change-Id: I96e5ce4d84f831a5a5818875b340208e7c344d8f
This commit is contained in:
Ilya Shakhat 2014-10-13 22:47:59 +04:00
parent 54695de3a1
commit b9cbe4e3d1
2 changed files with 40 additions and 22 deletions

View File

@ -2301,17 +2301,6 @@
"user_name": "Emilien Macchi",
"emails": ["emilien.macchi@stackops.com", "emilien.macchi@enovance.com", "emilien@enovance.com", "emacchi@redhat.com"]
},
{
"launchpad_id": "enchantner",
"user_name": "Nikolay Markov",
"companies": [
{
"company_name": "Mirantis",
"end_date": null
}
],
"emails": ["nmarkov@mirantis.com"]
},
{
"launchpad_id": "eric-martin4",
"companies": [
@ -3997,17 +3986,6 @@
"user_name": "Rui Chen",
"emails": ["chenrui.momo@gmail.com", "kiwik.chenrui@huawei.com"]
},
{
"launchpad_id": "kjharke",
"companies": [
{
"company_name": "HP",
"end_date": null
}
],
"user_name": "K Jonathan Harker",
"emails": ["k.jonathan.harker@hp.com"]
},
{
"launchpad_id": "koti-kelam",
"companies": [

View File

@ -88,3 +88,43 @@ class TestConfigFiles(testtools.TestCase):
def test_users_in_alphabetical_order_in_test_file(self):
self._verify_users_in_alphabetical_order('etc/test_default_data.json')
def _check_collision(self, storage, user, field, field_name):
self.assertFalse(
field in storage,
'Duplicate %s %s, collision between: %s and %s'
% (field_name, field, storage[field], user))
storage[field] = user
def _verify_users_unique(self, file_name):
users = self._read_file(file_name)['users']
storage = {}
for user in users:
if user.get('launchpad_id'):
field = user['launchpad_id']
self.assertFalse(
field in storage,
'Duplicate launchpad_id %s, collision between: %s and %s'
% (field, storage.get(field), user))
storage[field] = user
if user.get('gerrit_id'):
field = user['gerrit_id']
self.assertFalse(
('gerrit:%s' % field) in storage,
'Duplicate gerrit_id %s, collision between: %s and %s'
% (field, storage.get(field), user))
storage['gerrit:%s' % field] = user
for email in user['emails']:
self.assertFalse(
email in storage,
'Duplicate email %s, collision between: %s and %s'
% (email, storage.get(email), user))
storage[email] = user
def test_users_unique_profiles(self):
self._verify_users_unique('etc/default_data.json')
def test_users_unique_profiles_in_test_file(self):
self._verify_users_unique('etc/test_default_data.json')