BIND 10 trac213-incremental, updated. 1db4e8af5cf9a8600e8005807f0aa5109756c064 [213] More tests for component

BIND 10 source code commits bind10-changes at lists.isc.org
Sun Nov 6 12:17:05 UTC 2011


The branch, trac213-incremental has been updated
       via  1db4e8af5cf9a8600e8005807f0aa5109756c064 (commit)
      from  bfae9c1e78bcc1e94b4d5eef4d0bb9da1d42f30e (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 1db4e8af5cf9a8600e8005807f0aa5109756c064
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Sun Nov 6 13:15:40 2011 +0100

    [213] More tests for component

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

Summary of changes:
 src/lib/python/isc/bind10/tests/component_test.py |   56 +++++++++++++++++++++
 1 files changed, 56 insertions(+), 0 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/python/isc/bind10/tests/component_test.py b/src/lib/python/isc/bind10/tests/component_test.py
index 010f744..734cb1e 100644
--- a/src/lib/python/isc/bind10/tests/component_test.py
+++ b/src/lib/python/isc/bind10/tests/component_test.py
@@ -104,6 +104,8 @@ class ComponentTests(BossUtils, unittest.TestCase):
         self.__stop_called = False
         self.__failed_called = False
         self.__registered_processes = {}
+        self.__stop_process_params = None
+        self.__start_simple_params = None
 
     def __start(self):
         """
@@ -471,6 +473,60 @@ class ComponentTests(BossUtils, unittest.TestCase):
         self.assertEqual(42, component.pid())
         self.assertEqual(component, self.__registered_processes.get(42))
 
+    def stop_process(self, process, address):
+        """
+        Part of pretending to be boss.
+        """
+        self.__stop_process_params = (process, address)
+
+    def start_simple(self, process):
+        """
+        Part of pretending to be boss.
+        """
+        self.__start_simple_params = process
+
+    def test_component_start_stop_internal(self):
+        """
+        Test the behavior of _stop_internal and _start_internal.
+        """
+        component = Component('component', self, 'needed', 'Address')
+        component.start()
+        self.assertTrue(component.running())
+        self.assertEqual('component', self.__start_simple_params)
+        component.stop()
+        self.assertFalse(component.running())
+        self.assertEqual(('component', 'Address'), self.__stop_process_params)
+
+    def test_component_kill(self):
+        """
+        Check the kill is propagated. The case when component wasn't started
+        yet is already tested elsewhere.
+        """
+        class Process:
+            def __init__(self):
+                self.killed = False
+                self.terminated = False
+            def kill(self):
+                self.killed = True
+            def terminate(self):
+                self.terminated = True
+        process = Process()
+        class ProcInfo:
+            def __init__(self):
+                self.process = process
+                self.pid = 42
+        component = Component('component', self, 'needed', 'Address',
+                              [], ProcInfo)
+        component.start()
+        self.assertTrue(component.running())
+        component.kill()
+        self.assertTrue(process.terminated)
+        self.assertFalse(process.killed)
+        process.terminated = False
+        component.kill(True)
+        self.assertTrue(process.killed)
+        self.assertFalse(process.terminated)
+
 class TestComponent(BaseComponent):
     """
     A test component. It does not start any processes or so, it just logs




More information about the bind10-changes mailing list