[Elisa-commits] [MERGE]: frontend is in a plugin now, drop the backend idea

Alessandro Decina alessandro at fluendo.com
Mon Apr 21 16:03:30 CEST 2008


On Mon, Apr 21, 2008 at 3:28 PM, Benjamin Kampmann <benjamin at fluendo.com> wrote:
> Benjamin Kampmann schrieb:
> > This patch contains the new frontend base component and patch to the
> > interface controller. Beside this it contains a simple implementation
> > for a pigment frontend.

bb:tweak


+    def patch_application(self):
[snip]
+        class Application(object):
+            config = None
+            plugin_registry = None
+
+            def __init__(self):
+                self.counter = 0
+
+            def log_failure(self, failure):
+                self.counter += 1

What's counter for? It's never used.


+    def test_simple_initialize(self):
[snip]
+        # reset the interface controllers
+        self.interface_controller.frontends = {}

Resetting frontends to the empty dict is not needed here (and
in the other tests too).


+    def test_one_failed_initialize(self):
+        """
+        test that all other frontends get created even if one fails
+        """
+
+        config_string = """
+        [general]
+        frontends = ['frontend1', 'frontend2', 'frontend3']
+
+        [frontend1]
+        frontend = '1'
+
+        [frontend2]
+        frontend = 'failed'
+
+        [frontend3]
+        frontend = '3'
+        """
+        file_name = os.path.join(self.test_dir, 'failed_frontend_option.conf')
+        simple_config = Config(file_name, config_string)
+        common.application.config = simple_config

Looks like the creation of the config file could go in a
method of the test class.


+    def test_all_failed_initialize(self):
+        """
+        test that we get an errback, when creation of all frontends fails
+        """
+         # create a stimple config for testing
+        config_string = """
+        [general]
+        frontends = ['frontend1', 'frontend2', 'frontend3']
+
+        [frontend1]
+        frontend = 'failure'
+
+        [frontend2]
+        frontend = 'failed'
+
+        [frontend3]
+        """
+        file_name = os.path.join(self.test_dir, 'all_failed_test.conf')
+        simple_config = Config(file_name, config_string)
+        common.application.config = simple_config
+
+        # reset the interface controllers
+        self.interface_controller.frontends = {}
+
+        def rewrite_error(failure):
+            # we got a failure that we expected
+            if failure.type == NoFrontendCreated:
+                return
+            return failure
+
+        def got_callback(result):
+            self.fail("We don't want to get an callback")
+
+        dfr = self.interface_controller.initialize()
+        dfr.addCallback(got_callback)
+        dfr.addErrback(rewrite_error)
+
+        return dfr

You should use self.failUnlessFailure here.

Looks good.

Alessandro


More information about the Elisa-commits mailing list