Browse Source

[2016] check for single_update_mode

Jelte Jansen 13 years ago
parent
commit
6cf1a5f2d0
2 changed files with 17 additions and 0 deletions
  1. 6 0
      src/lib/python/isc/xfrin/diff.py
  2. 11 0
      src/lib/python/isc/xfrin/tests/diff_tests.py

+ 6 - 0
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
         If the result was NXDOMAIN or NXRRSET, and there are rrs in the
         additions buffer, the result is changed to SUCCESS.
         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)
         result, rrset, flags = self.find(name, rrtype)
 
 
         added_rrs = self.__get_name_type_from_additions(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,
         If the result was NXDOMAIN, and there are rrs in the additions buffer,
         the result is changed to SUCCESS.
         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)
         result, rrsets, flags = self.find_all(name)
         new_rrsets = []
         new_rrsets = []
         added_rrs = self.__get_name_from_additions(name)
         added_rrs = self.__get_name_from_additions(name)

+ 11 - 0
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.assertRaises(ValueError, diff_single.get_buffer)
         self.assertEqual(([], []), diff_single.get_single_update_buffers())
         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):
     def test_single_update_mode(self):
         '''
         '''
         Test single-update mode. In this mode, updates and deletes can
         Test single-update mode. In this mode, updates and deletes can