Parcourir la source

[1259] Test for the commit, first part

Only the commit itself, not yet that the rest of operations get disabled
by it.
Michal 'vorner' Vaner il y a 13 ans
Parent
commit
4bb4081381
1 fichiers modifiés avec 34 ajouts et 1 suppressions
  1. 34 1
      src/lib/python/isc/xfrin/tests/diff_tests.py

+ 34 - 1
src/lib/python/isc/xfrin/tests/diff_tests.py

@@ -35,6 +35,8 @@ class DiffTest(unittest.TestCase):
         self.__updater_requested = False
         self.__compact_called = False
         self.__data_operations = []
+        self.__apply_called = False
+        self.__commit_called = False
         # Some common values
         self.__rrclass = RRClass.IN()
         self.__type = RRType.A()
@@ -59,11 +61,25 @@ class DiffTest(unittest.TestCase):
 
     def __mock_compact(self):
         """
-        This can be put into the diff to hook into it's compact method and see
+        This can be put into the diff to hook into its compact method and see
         if it gets called.
         """
         self.__compact_called = True
 
+    def __mock_apply(self):
+        """
+        This can be put into the diff to hook into its apply method and see
+        it gets called.
+        """
+        self.__apply_called = True
+
+    def commit(self):
+        """
+        This is part of pretending to be a zone updater. This notes the commit
+        was called.
+        """
+        self.__commit_called = True
+
     def add_rrset(self, rrset):
         """
         This one is part of pretending to be a zone updater. It writes down
@@ -173,6 +189,23 @@ class DiffTest(unittest.TestCase):
         # got inside.
         self.assertEqual([], diff.get_buffer())
 
+    def test_commit(self):
+        """
+        If we call a commit, it should first apply whatever changes are
+        left (we hook into that instead of checking the effect) and then
+        the commit on the updater should have been called.
+
+        Then we check it raises value error for whatever operation we try.
+        """
+        diff = Diff(self, Name('example.org.'))
+        diff.add_data(self.__rrset1)
+        diff.apply = self.__mock_apply
+        diff.commit()
+        self.assertTrue(self.__apply_called)
+        self.assertTrue(self.__commit_called)
+        # The data should be handled by apply which we replaced.
+        self.assertEqual([], self.__data_operations)
+
 if __name__ == "__main__":
     isc.log.init("bind10")
     unittest.main()