def testRegisterComponent(self):
		"""
		Tests :meth:`manager.componentsManager.Manager.registerComponent` method.
		"""

		manager = Manager()
		self.assertTrue(manager.registerComponent(SINGLE_COMPONENT[1]))
		self.assertIn(SINGLE_COMPONENT[0], manager.components)
    def testRegisterComponent(self):
        """
		Tests :meth:`manager.componentsManager.Manager.registerComponent` method.
		"""

        manager = Manager()
        self.assertTrue(manager.registerComponent(SINGLE_COMPONENT[1]))
        self.assertIn(SINGLE_COMPONENT[0], manager.components)
	def test__len__(self):
		"""
		Tests :meth:`manager.componentsManager.Manager.__len__` method.
		"""

		manager = Manager([os.path.join(COMPONENTS_DIRECTORY, item) for item in COMPONENTS])
		manager.registerComponents()
		self.assertEqual(3, len(manager))
	def testGetComponentAttributeName(self):
		"""
		Tests :meth:`manager.componentsManager.Manager.getComponentAttributeName` method.
		"""

		self.assertEquals(Manager.getComponentAttributeName("factory.componentsManagerUi"), "factoryComponentsManagerUi")
		self.assertEquals(Manager.getComponentAttributeName("addons.loggingNotifier"), "addonsLoggingNotifier")
		self.assertEquals(Manager.getComponentAttributeName("myComponent"), "myComponent")
    def test__len__(self):
        """
		Tests :meth:`manager.componentsManager.Manager.__len__` method.
		"""

        manager = Manager(
            [os.path.join(COMPONENTS_DIRECTORY, item) for item in COMPONENTS])
        manager.registerComponents()
        self.assertEqual(3, len(manager))
	def testInstantiateComponent(self):
		"""
		Tests :meth:`manager.componentsManager.Manager.instantiateComponent` method.
		"""

		manager = Manager()
		manager.registerComponent(SINGLE_COMPONENT[1])
		self.assertTrue(manager.instantiateComponent(SINGLE_COMPONENT[0], managerCallback))
		self.assertIsInstance(manager.components.values()[0].interface, SINGLE_COMPONENT[2])
	def test__getitem__(self):
		"""
		Tests :meth:`manager.componentsManager.Manager.__getitem__` method.
		"""

		manager = Manager([os.path.join(COMPONENTS_DIRECTORY, item) for item in COMPONENTS])
		manager.registerComponents()
		manager.instantiateComponents()
		for name, profile in manager:
			self.assertIsInstance(manager[name], Component)
    def testInstantiateComponent(self):
        """
		Tests :meth:`manager.componentsManager.Manager.instantiateComponent` method.
		"""

        manager = Manager()
        manager.registerComponent(SINGLE_COMPONENT[1])
        self.assertTrue(
            manager.instantiateComponent(SINGLE_COMPONENT[0], managerCallback))
        self.assertIsInstance(manager.components.values()[0].interface,
                              SINGLE_COMPONENT[2])
	def test__contains__(self):
		"""
		Tests :meth:`manager.componentsManager.Manager.__contains__` method.
		"""

		componentsPaths = [os.path.join(COMPONENTS_DIRECTORY, item) for item in COMPONENTS]
		componentsPaths.append(ALTERNATIVE_COMPONENTS_DIRECTORY)
		manager = Manager(componentsPaths)
		manager.registerComponents()
		for component in COMPONENTS_NAMES:
			self.assertIn(component, manager)
	def test__iter__(self):
		"""
		Tests :meth:`manager.componentsManager.Manager.__iter__` method.
		"""

		componentsPaths = [os.path.join(COMPONENTS_DIRECTORY, item) for item in COMPONENTS]
		componentsPaths.append(ALTERNATIVE_COMPONENTS_DIRECTORY)
		manager = Manager(componentsPaths)
		manager.registerComponents()
		for name, profile in manager:
			self.assertIn(name, COMPONENTS_NAMES)
			self.assertIsInstance(profile, Profile)
	def testRegisterComponents(self):
		"""
		Tests :meth:`manager.componentsManager.Manager.registerComponents` method.
		"""

		componentsPaths = [os.path.join(COMPONENTS_DIRECTORY, item) for item in COMPONENTS]
		componentsPaths.append(ALTERNATIVE_COMPONENTS_DIRECTORY)
		manager = Manager(componentsPaths)
		manager.registerComponents()
		self.assertIsInstance(manager.components, dict)
		for component in ("{0}.{1}".format(item, name) for item in COMPONENTS for name in COMPONENTS[item]):
			self.assertIn(component, manager.components)
    def testGetComponentAttributeName(self):
        """
		Tests :meth:`manager.componentsManager.Manager.getComponentAttributeName` method.
		"""

        self.assertEquals(
            Manager.getComponentAttributeName("factory.componentsManagerUi"),
            "factoryComponentsManagerUi")
        self.assertEquals(
            Manager.getComponentAttributeName("addons.loggingNotifier"),
            "addonsLoggingNotifier")
        self.assertEquals(Manager.getComponentAttributeName("myComponent"),
                          "myComponent")
    def test__contains__(self):
        """
		Tests :meth:`manager.componentsManager.Manager.__contains__` method.
		"""

        componentsPaths = [
            os.path.join(COMPONENTS_DIRECTORY, item) for item in COMPONENTS
        ]
        componentsPaths.append(ALTERNATIVE_COMPONENTS_DIRECTORY)
        manager = Manager(componentsPaths)
        manager.registerComponents()
        for component in COMPONENTS_NAMES:
            self.assertIn(component, manager)
    def test__iter__(self):
        """
		Tests :meth:`manager.componentsManager.Manager.__iter__` method.
		"""

        componentsPaths = [
            os.path.join(COMPONENTS_DIRECTORY, item) for item in COMPONENTS
        ]
        componentsPaths.append(ALTERNATIVE_COMPONENTS_DIRECTORY)
        manager = Manager(componentsPaths)
        manager.registerComponents()
        for name, profile in manager:
            self.assertIn(name, COMPONENTS_NAMES)
            self.assertIsInstance(profile, Profile)
    def testRegisterComponents(self):
        """
		Tests :meth:`manager.componentsManager.Manager.registerComponents` method.
		"""

        componentsPaths = [
            os.path.join(COMPONENTS_DIRECTORY, item) for item in COMPONENTS
        ]
        componentsPaths.append(ALTERNATIVE_COMPONENTS_DIRECTORY)
        manager = Manager(componentsPaths)
        manager.registerComponents()
        self.assertIsInstance(manager.components, dict)
        for component in ("{0}.{1}".format(item, name) for item in COMPONENTS
                          for name in COMPONENTS[item]):
            self.assertIn(component, manager.components)
    def testReloadComponent(self):
        """
		Tests :meth:`manager.componentsManager.Manager.reloadComponent` method.
		"""

        manager = Manager(
            [os.path.join(COMPONENTS_DIRECTORY, item) for item in COMPONENTS])
        manager.registerComponents()
        manager.instantiateComponents()
        for component in manager.components:
            manager.reloadComponent(component)
    def testUnregisterComponents(self):
        """
		Tests :meth:`manager.componentsManager.Manager.unregisterComponents` method.
		"""

        manager = Manager(
            [os.path.join(COMPONENTS_DIRECTORY, item) for item in COMPONENTS])
        manager.registerComponents()
        manager.instantiateComponents()
        manager.unregisterComponents()
        self.assertTrue(not manager.components)
	def testUnregisterComponents(self):
		"""
		Tests :meth:`manager.componentsManager.Manager.unregisterComponents` method.
		"""

		manager = Manager([os.path.join(COMPONENTS_DIRECTORY, item) for item in COMPONENTS])
		manager.registerComponents()
		manager.instantiateComponents()
		manager.unregisterComponents()
		self.assertTrue(not manager.components)
	def testReloadComponent(self):
		"""
		Tests :meth:`manager.componentsManager.Manager.reloadComponent` method.
		"""

		manager = Manager([os.path.join(COMPONENTS_DIRECTORY, item) for item in COMPONENTS])
		manager.registerComponents()
		manager.instantiateComponents()
		for component in manager.components:
			manager.reloadComponent(component)
    def testGetInterface(self):
        """
		Tests :meth:`manager.componentsManager.Manager.getInterface` method.
		"""

        manager = Manager(
            [os.path.join(COMPONENTS_DIRECTORY, item) for item in COMPONENTS])
        manager.registerComponents()
        manager.instantiateComponents()
        for component in manager.components:
            self.assertIsInstance(manager.getInterface(component), Component)
    def testFilterComponents(self):
        """
		Tests :meth:`manager.componentsManager.Manager.filterComponents` method.
		"""

        manager = Manager(
            [os.path.join(COMPONENTS_DIRECTORY, item) for item in COMPONENTS])
        manager.registerComponents()
        manager.instantiateComponents()
        components = manager.filterComponents("addons")
        self.assertIsInstance(components, list)
        self.assertListEqual(components, ["addons.testsComponentC"])
	def testGetInterface(self):
		"""
		Tests :meth:`manager.componentsManager.Manager.getInterface` method.
		"""

		manager = Manager([os.path.join(COMPONENTS_DIRECTORY, item) for item in COMPONENTS])
		manager.registerComponents()
		manager.instantiateComponents()
		for component in manager.components:
			self.assertIsInstance(manager.getInterface(component), Component)
	def testListComponents(self):
		"""
		Tests :meth:`manager.componentsManager.Manager.listComponents` method.
		"""

		componentsPaths = [os.path.join(COMPONENTS_DIRECTORY, item) for item in COMPONENTS]
		componentsPaths.append(ALTERNATIVE_COMPONENTS_DIRECTORY)
		manager = Manager(componentsPaths)
		manager.registerComponents()
		manager.instantiateComponents()
		components = manager.listComponents()
		self.assertIsInstance(components, list)
		self.assertListEqual(components, COMPONENTS_DEPENDENCY_ORDER)
		self.assertListEqual(sorted(manager.listComponents(dependencyOrder=False)), sorted(COMPONENTS_DEPENDENCY_ORDER))
    def testListComponents(self):
        """
		Tests :meth:`manager.componentsManager.Manager.listComponents` method.
		"""

        componentsPaths = [
            os.path.join(COMPONENTS_DIRECTORY, item) for item in COMPONENTS
        ]
        componentsPaths.append(ALTERNATIVE_COMPONENTS_DIRECTORY)
        manager = Manager(componentsPaths)
        manager.registerComponents()
        manager.instantiateComponents()
        components = manager.listComponents()
        self.assertIsInstance(components, list)
        self.assertListEqual(components, COMPONENTS_DEPENDENCY_ORDER)
        self.assertListEqual(
            sorted(manager.listComponents(dependencyOrder=False)),
            sorted(COMPONENTS_DEPENDENCY_ORDER))
    def test__getitem__(self):
        """
		Tests :meth:`manager.componentsManager.Manager.__getitem__` method.
		"""

        manager = Manager(
            [os.path.join(COMPONENTS_DIRECTORY, item) for item in COMPONENTS])
        manager.registerComponents()
        manager.instantiateComponents()
        for name, profile in manager:
            self.assertIsInstance(manager[name], Component)
	def testFilterComponents(self):
		"""
		Tests :meth:`manager.componentsManager.Manager.filterComponents` method.
		"""

		manager = Manager([os.path.join(COMPONENTS_DIRECTORY, item) for item in COMPONENTS])
		manager.registerComponents()
		manager.instantiateComponents()
		components = manager.filterComponents("addons")
		self.assertIsInstance(components, list)
		self.assertListEqual(components, ["addons.testsComponentC"])
    def testListDependents(self):
        """
		Tests :meth:`manager.componentsManager.Manager.listDependents` method.
		"""

        componentsPaths = [
            os.path.join(COMPONENTS_DIRECTORY, item) for item in COMPONENTS
        ]
        componentsPaths.append(ALTERNATIVE_COMPONENTS_DIRECTORY)
        manager = Manager(componentsPaths)
        manager.registerComponents()
        manager.instantiateComponents()
        for name, profile in manager:
            self.assertListEqual(sorted(COMPONENTS_DEPENDENTS[name]),
                                 sorted(manager.listDependents(name)))
	def testListDependents(self):
		"""
		Tests :meth:`manager.componentsManager.Manager.listDependents` method.
		"""

		componentsPaths = [os.path.join(COMPONENTS_DIRECTORY, item) for item in COMPONENTS]
		componentsPaths.append(ALTERNATIVE_COMPONENTS_DIRECTORY)
		manager = Manager(componentsPaths)
		manager.registerComponents()
		manager.instantiateComponents()
		for name, profile in manager:
			self.assertListEqual(sorted(COMPONENTS_DEPENDENTS[name]), sorted(manager.listDependents(name)))
	def testInstantiateComponents(self):
		"""
		Tests :meth:`manager.componentsManager.Manager.instantiateComponents` method.
		"""

		manager = Manager([os.path.join(COMPONENTS_DIRECTORY, item) for item in COMPONENTS])
		manager.registerComponents()
		manager.instantiateComponents()
		for component in manager.components.itervalues():
			self.assertIsInstance(component.interface, Component)
		manager.unregisterComponents()
		manager.registerComponents()
		manager.instantiateComponents(managerCallback)
		for component in manager.components.itervalues():
			self.assertTrue(component.callback)
    def testInstantiateComponents(self):
        """
		Tests :meth:`manager.componentsManager.Manager.instantiateComponents` method.
		"""

        manager = Manager(
            [os.path.join(COMPONENTS_DIRECTORY, item) for item in COMPONENTS])
        manager.registerComponents()
        manager.instantiateComponents()
        for component in manager.components.itervalues():
            self.assertIsInstance(component.interface, Component)
        manager.unregisterComponents()
        manager.registerComponents()
        manager.instantiateComponents(managerCallback)
        for component in manager.components.itervalues():
            self.assertTrue(component.callback)