Browse Source

[2225_xfrout] update the counter object and its getter method according to the new interface

It raises DataNotFoundError instead of zero-count on the new interface when the
getter method is invoked if its counter hasn't been incremented yet
Naoki Kambe 12 years ago
parent
commit
f8220e0111
1 changed files with 24 additions and 8 deletions
  1. 24 8
      src/lib/python/isc/notify/tests/notify_out_test.py

+ 24 - 8
src/lib/python/isc/notify/tests/notify_out_test.py

@@ -266,8 +266,12 @@ class TestNotifyOut(unittest.TestCase):
     def test_send_notify_message_udp_ipv4(self):
     def test_send_notify_message_udp_ipv4(self):
         example_com_info = self._notify._notify_infos[('example.net.', 'IN')]
         example_com_info = self._notify._notify_infos[('example.net.', 'IN')]
 
 
-        self.assertEqual(Counter.get_notifyoutv4('example.net.'), 0)
-        self.assertEqual(Counter.get_notifyoutv6('example.net.'), 0)
+        self.assertRaises(isc.cc.data.DataNotFoundError,
+                          self._notify._counter.get,
+                          'zones', 'example.net.', 'notifyoutv4')
+        self.assertRaises(isc.cc.data.DataNotFoundError,
+                          self._notify._counter.get,
+                          'zones', 'example.net.', 'notifyoutv6')
 
 
         example_com_info.prepare_notify_out()
         example_com_info.prepare_notify_out()
         ret = self._notify._send_notify_message_udp(example_com_info,
         ret = self._notify._send_notify_message_udp(example_com_info,
@@ -282,8 +286,12 @@ class TestNotifyOut(unittest.TestCase):
     def test_send_notify_message_udp_ipv6(self):
     def test_send_notify_message_udp_ipv6(self):
         example_com_info = self._notify._notify_infos[('example.net.', 'IN')]
         example_com_info = self._notify._notify_infos[('example.net.', 'IN')]
 
 
-        self.assertEqual(Counter.get_notifyoutv4('example.net.'), 0)
-        self.assertEqual(Counter.get_notifyoutv6('example.net.'), 0)
+        self.assertRaises(isc.cc.data.DataNotFoundError,
+                          self._notify._counter.get,
+                          'zones', 'example.net.', 'notifyoutv4')
+        self.assertRaises(isc.cc.data.DataNotFoundError,
+                          self._notify._counter.get,
+                          'zones', 'example.net.', 'notifyoutv6')
 
 
         ret = self._notify._send_notify_message_udp(example_com_info,
         ret = self._notify._send_notify_message_udp(example_com_info,
                                                     ('2001:db8::53', 53))
                                                     ('2001:db8::53', 53))
@@ -297,8 +305,12 @@ class TestNotifyOut(unittest.TestCase):
     def test_send_notify_message_with_bogus_address(self):
     def test_send_notify_message_with_bogus_address(self):
         example_com_info = self._notify._notify_infos[('example.net.', 'IN')]
         example_com_info = self._notify._notify_infos[('example.net.', 'IN')]
 
 
-        self.assertEqual(Counter.get_notifyoutv4('example.net.'), 0)
-        self.assertEqual(Counter.get_notifyoutv6('example.net.'), 0)
+        self.assertRaises(isc.cc.data.DataNotFoundError,
+                          self._notify._counter.get,
+                          'zones', 'example.net.', 'notifyoutv4')
+        self.assertRaises(isc.cc.data.DataNotFoundError,
+                          self._notify._counter.get,
+                          'zones', 'example.net.', 'notifyoutv6')
 
 
         # As long as the underlying data source validates RDATA this shouldn't
         # As long as the underlying data source validates RDATA this shouldn't
         # happen, but right now it's not actually the case.  Even if the
         # happen, but right now it's not actually the case.  Even if the
@@ -308,8 +320,12 @@ class TestNotifyOut(unittest.TestCase):
                                                     ('invalid', 53))
                                                     ('invalid', 53))
         self.assertFalse(ret)
         self.assertFalse(ret)
 
 
-        self.assertEqual(Counter.get_notifyoutv4('example.net.'), 0)
-        self.assertEqual(Counter.get_notifyoutv6('example.net.'), 0)
+        self.assertRaises(isc.cc.data.DataNotFoundError,
+                          self._notify._counter.get,
+                          'zones', 'example.net.', 'notifyoutv4')
+        self.assertRaises(isc.cc.data.DataNotFoundError,
+                          self._notify._counter.get,
+                          'zones', 'example.net.', 'notifyoutv4')
 
 
     def test_zone_notify_handler(self):
     def test_zone_notify_handler(self):
         old_send_msg = self._notify._send_notify_message_udp
         old_send_msg = self._notify._send_notify_message_udp