]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2016] check for single_update_mode
authorJelte Jansen <jelte@isc.org>
Thu, 7 Jun 2012 13:50:43 +0000 (15:50 +0200)
committerJelte Jansen <jelte@isc.org>
Thu, 7 Jun 2012 13:50:43 +0000 (15:50 +0200)
src/lib/python/isc/xfrin/diff.py
src/lib/python/isc/xfrin/tests/diff_tests.py

index 234433ad5ca5c9f7307c11ff9557effa78ff6b83..ea51967c30f9aa9e466c1486f4f39e9f1b70885a 100644 (file)
@@ -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)
index bedd305ad7ff601eb8c2201208ee3171e2444347..f6137bc941d0af2fae66059c47f233664d1e20aa 100644 (file)
@@ -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