]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2018] Use updater instead of separate finders
authorJelte Jansen <jelte@isc.org>
Mon, 4 Jun 2012 12:26:05 +0000 (14:26 +0200)
committerJelte Jansen <jelte@isc.org>
Mon, 4 Jun 2012 12:26:05 +0000 (14:26 +0200)
src/lib/python/isc/ddns/session.py
src/lib/python/isc/ddns/tests/session_tests.py
src/lib/python/isc/xfrin/diff.py

index ff30b6765a45b9168d200b3c06b10e91f1f2a943..fa51d0e5f9f1c83d495101608613ddf91a0b4fae 100644 (file)
@@ -247,7 +247,12 @@ class UpdateSession:
             self.__diff = isc.xfrin.diff.Diff(datasrc_client, zname,
                                               journaling=True,
                                               single_update_mode=True)
-            _, self.__finder = datasrc_client.find_zone(zname)
+            # Note that while it is really the ZoneUpdater that is set
+            # here, it is still called finder, as the only methods that
+            # are and should be used on this object are find() and find_all()
+            # (ZoneUpdater provides the ZoneFinder interface itself, no
+            # separate get_zone_finder())
+            self.__finder = self.__diff.get_updater()
             self.__zname = zname
             self.__zclass = zclass
             self.__datasrc_client = datasrc_client
@@ -591,7 +596,7 @@ class UpdateSession:
                                                    rrset.get_type(),
                                                    ZoneFinder.NO_WILDCARD |
                                                    ZoneFinder.FIND_GLUE_OK)
-        if result == self.__finder.CNAME:
+        if result == ZoneFinder.CNAME:
             # Ignore non-cname rrs that try to update CNAME records
             # (if rrset itself is a CNAME, the finder result would be
             # SUCCESS, see next case)
index 87cd255cf27ea4a72e3776ef70cdf1fe767d1b8c..cbcac128aa36b4cac586c6daac3f582dd95b4fc1 100644 (file)
@@ -114,6 +114,12 @@ class SessionTestBase(unittest.TestCase):
                                                  self._acl_map))
         self._session._UpdateSession__get_update_zone()
 
+    def tearDown(self):
+        # With the Updater created in __get_update_zone, and tests
+        # doing all kinds of crazy stuff, one might get database locked
+        # errors if it doesn't clean up explicitely after each test
+        self._session = None
+
     def check_response(self, msg, expected_rcode):
         '''Perform common checks on update resposne message.'''
         self.assertTrue(msg.get_header_flag(Message.HEADERFLAG_QR))
@@ -282,12 +288,6 @@ class SessionTest(SessionTestBase):
 
         self.assertEqual(expected, strings)
 
-    def __prereq_helper(self, method, expected, rrset):
-        '''Calls the given method with self._datasrc_client
-           and the given rrset, and compares the return value.
-           Function does not do much but makes the code look nicer'''
-        self.assertEqual(expected, method(rrset))
-
     def __check_prerequisite_exists_combined(self, method, rrclass, expected):
         '''shared code for the checks for the very similar (but reversed
            in behaviour) methods __prereq_rrset_exists and
index 2d3f93736c094aa1a9638ce5d3ff63b7079c3f01..a3a9d7d08a968ac95b6de3d37b24d6d5fd97c2d5 100644 (file)
@@ -376,3 +376,13 @@ class Diff:
             raise ValueError("Separate buffers requested in single-update mode")
         else:
             return (self.__deletions, self.__additions)
+
+    def get_updater(self):
+        """
+        Returns the ZoneUpdater associated with this Diff instance.
+        While update statements can be used on this updater, its main
+        goal is to provide the ZoneFinder interface for searching through
+        the zone as it was on the moment the updater was created.
+        If the Diff has been committed, this will return None.
+        """
+        return self.__updater