From b9cbe4e3d1406a17b0f1fb092afa6fd14f7275c1 Mon Sep 17 00:00:00 2001 From: Ilya Shakhat Date: Mon, 13 Oct 2014 22:47:59 +0400 Subject: [PATCH] Remove duplicates from default_data.json Also added test to prevent dups in the future Change-Id: I96e5ce4d84f831a5a5818875b340208e7c344d8f --- etc/default_data.json | 22 ------------------ tests/unit/test_config_files.py | 40 +++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 22 deletions(-) diff --git a/etc/default_data.json b/etc/default_data.json index f474364cf..2cf5762eb 100644 --- a/etc/default_data.json +++ b/etc/default_data.json @@ -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": [ diff --git a/tests/unit/test_config_files.py b/tests/unit/test_config_files.py index 427f5d1fd..e5de38608 100644 --- a/tests/unit/test_config_files.py +++ b/tests/unit/test_config_files.py @@ -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')