def test_id_policy(self): """ id policy """ # If no Id is specified then use 'module_name.class_name'. p = Plugin() self.assertEqual("envisage.plugin.Plugin", p.id) # If an Id is specified make sure we use it! p = Plugin(id="wilma") self.assertEqual("wilma", p.id) # Make sure setting the name doesn't interfere with the Id. p = Plugin(name="fred", id="wilma") self.assertEqual("wilma", p.id) self.assertEqual("fred", p.name)
def test_name_policy(self): """ name policy """ # If name is specified then use the plugin's class name. p = Plugin() self.assertEqual("Plugin", p.name) # If a name is specified make sure we use it! p = Plugin(name="wilma") self.assertEqual("wilma", p.name) # Try a camel case plugin class. class ThisIsMyPlugin(Plugin): pass p = ThisIsMyPlugin() self.assertEqual("This Is My Plugin", p.name)
def test_plugin_str_representation(self): """ test the string representation of the plugin """ plugin_repr = "Plugin(id={!r}, name={!r})" plugin = Plugin(id="Fred", name="Wilma") self.assertEqual(plugin_repr.format("Fred", "Wilma"), str(plugin)) self.assertEqual(plugin_repr.format("Fred", "Wilma"), repr(plugin))