From: Jelte Jansen Date: Thu, 7 Jun 2012 13:50:43 +0000 (+0200) Subject: [2016] check for single_update_mode X-Git-Tag: trac2351_base~226^2~58^2~5^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6cf1a5f2d046ea30dab739bd907b90dcde04160e;p=thirdparty%2Fkea.git [2016] check for single_update_mode --- diff --git a/src/lib/python/isc/xfrin/diff.py b/src/lib/python/isc/xfrin/diff.py index 234433ad5c..ea51967c30 100644 --- a/src/lib/python/isc/xfrin/diff.py +++ b/src/lib/python/isc/xfrin/diff.py @@ -506,6 +506,9 @@ class Diff: If the result was NXDOMAIN or NXRRSET, and there are rrs in the additions buffer, the result is changed to SUCCESS. ''' + if not self.__single_update_mode: + raise ValueError("find_updated() can only be used in " + + "single-update mode") result, rrset, flags = self.find(name, rrtype) added_rrs = self.__get_name_type_from_additions(name, rrtype) @@ -556,6 +559,9 @@ class Diff: If the result was NXDOMAIN, and there are rrs in the additions buffer, the result is changed to SUCCESS. ''' + if not self.__single_update_mode: + raise ValueError("find_all_updated can only be used in " + + "single-update mode") result, rrsets, flags = self.find_all(name) new_rrsets = [] added_rrs = self.__get_name_from_additions(name) diff --git a/src/lib/python/isc/xfrin/tests/diff_tests.py b/src/lib/python/isc/xfrin/tests/diff_tests.py index bedd305ad7..f6137bc941 100644 --- a/src/lib/python/isc/xfrin/tests/diff_tests.py +++ b/src/lib/python/isc/xfrin/tests/diff_tests.py @@ -551,6 +551,17 @@ class DiffTest(unittest.TestCase): self.assertRaises(ValueError, diff_single.get_buffer) self.assertEqual(([], []), diff_single.get_single_update_buffers()) + def test_finds_single(self): + ''' + Test that find_updated() and find_all_updated() can only be used + in single-update-mode. + ''' + diff_multi = Diff(self, Name('example.org.'), single_update_mode=False) + self.assertRaises(ValueError, diff_multi.find_updated, + Name('example.org.'), RRType.A()) + self.assertRaises(ValueError, diff_multi.find_all_updated, + Name('example.org.')) + def test_single_update_mode(self): ''' Test single-update mode. In this mode, updates and deletes can