~therve/landscape-client/sysinfo-network-disks

« back to all changes in this revision

Viewing changes to landscape/manager/tests/test_eucalyptus.py

  • Committer: Jamu Kakar
  • Date: 2010-02-04 01:07:35 UTC
  • mto: This revision was merged to the branch mainline in revision 204.
  • Revision ID: jkakar@kakar.ca-20100204010735-umhonk79bk29gmgj
- Added (an untested) remove method to PluginRegistry.
- Added some initial tests for the plugin.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from landscape.manager.eucalyptus import EucalyptusCloudManager
 
2
from landscape.tests.helpers import LandscapeTest, ManagerHelper
 
3
 
 
4
 
 
5
class EucalyptusCloudManagerTest(LandscapeTest):
 
6
 
 
7
    helpers = [ManagerHelper]
 
8
 
 
9
    def setUp(self):
 
10
        super(EucalyptusCloudManagerTest, self).setUp()
 
11
        message_type = EucalyptusCloudManager.message_type
 
12
        self.broker_service.message_store.set_accepted_types([message_type])
 
13
        self.plugin = EucalyptusCloudManager()
 
14
        self.manager.add(self.plugin)
 
15
 
 
16
    def test_plugin_registers_with_a_name(self):
 
17
        """
 
18
        L{EucalyptusCloudManager} provides a C{plugin_name}, which is used
 
19
        when the plugin is registered with the manager plugin registry.
 
20
        """
 
21
        plugin_name = self.plugin.plugin_name
 
22
        self.assertIs(self.plugin, self.manager.get_plugin(plugin_name))
 
23
 
 
24
    def test_wb_plugin_deregisters_on_imagestore_import_fail(self):
 
25
        """
 
26
        When L{EucalyptusCloudManager.run} is called it tries to import code
 
27
        from the C{imagestore} package.  The plugin disables itself if an
 
28
        exception is raised during this process.
 
29
        """
 
30
        plugin_name = self.plugin.plugin_name
 
31
        self.assertIs(self.plugin, self.manager.get_plugin(plugin_name))
 
32
        self.plugin._start_service_hub = lambda: 1/0
 
33
        self.plugin.run()
 
34
        self.assertRaises(KeyError, self.manager.get_plugin, plugin_name)