diff options
author | Petr Viktorin <pviktori@redhat.com> | 2013-09-23 10:46:01 +0200 |
---|---|---|
committer | Petr Viktorin <pviktori@redhat.com> | 2013-09-25 10:13:56 +0200 |
commit | a93fc02af6eb50ecb0cfc69174c9f385d60bbbb3 (patch) | |
tree | 9c1150ddd8274aad85af93596bd3fba092c75def /ipatests | |
parent | 0226064baced57f09b899370752c63cce8009b61 (diff) | |
download | freeipa-a93fc02af6eb50ecb0cfc69174c9f385d60bbbb3.tar.gz freeipa-a93fc02af6eb50ecb0cfc69174c9f385d60bbbb3.tar.xz freeipa-a93fc02af6eb50ecb0cfc69174c9f385d60bbbb3.zip |
Raise an error when updating CIDict with duplicate keys
Updating a CIDict with data like {'A': 1, 'a': 2} would lead to data
loss since only one of the items would get to the CIDict.
This can result in non-obvious bugs similar to this one in python-ldap:
https://bugzilla.redhat.com/show_bug.cgi?id=1007820
Raise an error in this case; any resolution must be done by the caller.
Diffstat (limited to 'ipatests')
-rw-r--r-- | ipatests/test_ipapython/test_ipautil.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/ipatests/test_ipapython/test_ipautil.py b/ipatests/test_ipapython/test_ipautil.py index a8a73edcd..04a43990e 100644 --- a/ipatests/test_ipapython/test_ipautil.py +++ b/ipatests/test_ipapython/test_ipautil.py @@ -243,6 +243,18 @@ class TestCIDict(object): 'a': 'va', 'b': 'vb', 'Key1': 'val1', 'key2': 'val2', 'KEY3': 'VAL3'} + def test_update_duplicate_values_dict(self): + with nose.tools.assert_raises(ValueError): + self.cidict.update({'a': 'va', 'A': None, 'b': 3}) + + def test_update_duplicate_values_list(self): + with nose.tools.assert_raises(ValueError): + self.cidict.update([('a', 'va'), ('A', None), ('b', 3)]) + + def test_update_duplicate_values_kwargs(self): + with nose.tools.assert_raises(ValueError): + self.cidict.update(a='va', A=None, b=3) + def test_update_kwargs(self): self.cidict.update(b='vb', key2='val2') assert dict(self.cidict.items()) == { |