BIND 10 trac2439, updated. f0ad7b6307f49bb7bc4a45311e6f1b33b42dd885 [2439] Provide an rrset collection from Diff

BIND 10 source code commits bind10-changes at lists.isc.org
Tue Jan 22 11:51:42 UTC 2013


The branch, trac2439 has been updated
       via  f0ad7b6307f49bb7bc4a45311e6f1b33b42dd885 (commit)
      from  f485d39ab6e394bc034b990f872572c3700d0312 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit f0ad7b6307f49bb7bc4a45311e6f1b33b42dd885
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Tue Jan 22 12:50:10 2013 +0100

    [2439] Provide an rrset collection from Diff
    
    Let the Diff pass an rrset collection from within the internal updater.

-----------------------------------------------------------------------

Summary of changes:
 src/lib/python/isc/xfrin/diff.py             |   13 ++++++++++
 src/lib/python/isc/xfrin/tests/diff_tests.py |   34 +++++++++++++++++++++++++-
 2 files changed, 46 insertions(+), 1 deletion(-)

-----------------------------------------------------------------------
diff --git a/src/lib/python/isc/xfrin/diff.py b/src/lib/python/isc/xfrin/diff.py
index ea51967..2d063ae 100644
--- a/src/lib/python/isc/xfrin/diff.py
+++ b/src/lib/python/isc/xfrin/diff.py
@@ -584,3 +584,16 @@ class Diff:
             if rr.get_name() == name:
                 new_rrsets.append(rr)
         return result, new_rrsets, flags
+
+    def get_rrset_collection(self):
+        '''
+        This first applies all changes to the data source. Then it creates
+        and returns an RRsetCollection on top of the corresponding zone
+        updater and returns it. Notice it might be impossible to apply more
+        changes after that.
+
+        This must not be called after a commit, or it'd throw ValueError.
+        '''
+        # Apply itself will check it is not yet commited.
+        self.apply()
+        return self.__updater.get_rrset_collection()
diff --git a/src/lib/python/isc/xfrin/tests/diff_tests.py b/src/lib/python/isc/xfrin/tests/diff_tests.py
index 906406f..72dc8bb 100644
--- a/src/lib/python/isc/xfrin/tests/diff_tests.py
+++ b/src/lib/python/isc/xfrin/tests/diff_tests.py
@@ -16,7 +16,7 @@
 import isc.log
 import unittest
 from isc.datasrc import ZoneFinder
-from isc.dns import Name, RRset, RRClass, RRType, RRTTL, Rdata
+from isc.dns import Name, RRset, RRClass, RRType, RRTTL, Rdata, RRsetCollection
 from isc.xfrin.diff import Diff, NoSuchZone
 
 class TestError(Exception):
@@ -1087,6 +1087,38 @@ class DiffTest(unittest.TestCase):
             self.__check_find_all_call(diff.find_all, self.__rrset3,
                                        rcode)
 
+    class Collection:
+        '''
+        Our own mock RRsetCollection. We don't use it, just pass it through.
+        This is to implement the below method.
+        '''
+        # Any idea why python doesn't agree with inheriting from
+        # dns.RRsetCollection?
+        pass
+
+    def get_rrset_collection(self):
+        '''
+        Part of pretending to be the zone updater. This returns the rrset
+        collection (a mock one, unuseable) for the updater.
+        '''
+        return self.Collection()
+
+    def test_get_rrset_collection(self):
+        '''
+        Test the diff can return corresponding rrset collection. Test
+        it applies the data first.
+        '''
+        diff = Diff(self, Name('example.org'), single_update_mode=True)
+        diff.add_data(self.__rrset_soa)
+        collection = diff.get_rrset_collection()
+        # Check it is commited
+        self.assertEqual(1, len(self.__data_operations))
+        self.assertEqual('add', self.__data_operations[0][0])
+        # Check the returned one is actually RRsetCollection
+        self.assertTrue(collection, self.Collection)
+        # We don't call anything on the collection. It's just the mock from
+        # above, so it wouldn't be any good.
+
 if __name__ == "__main__":
     isc.log.init("bind10")
     isc.log.resetUnitTestRootLogger()



More information about the bind10-changes mailing list