Beispiel #1
0
    def test_get_manager_invalid_type(self):
        """
        Tests retrieving a manager instance but passing a bad type ID.
        """

        # Test
        try:
            factory.get_manager('foo')
            self.fail('Invalid manager type did not raise an exception')
        except factory.InvalidType, e:
            self.assertEqual(e.type_key, 'foo')
            self.assertEqual(str(e), 'Invalid manager type requested [foo]')
Beispiel #2
0
    def test_get_manager_invalid_type(self):
        """
        Tests retrieving a manager instance but passing a bad type ID.
        """

        # Test
        try:
            factory.get_manager('foo')
            self.fail('Invalid manager type did not raise an exception')
        except factory.InvalidType, e:
            self.assertEqual(e.type_key, 'foo')
            self.assertEqual(str(e), 'Invalid manager type requested [foo]')
Beispiel #3
0
    def test_register_and_reset(self):
        """
        Tests that registering a new class and resetting properly affects the
        class mappings.
        """

        # Setup
        class FakeManager:
            pass

        factory.register_manager(factory.TYPE_REPO, FakeManager)

        # Test Register
        manager = factory.get_manager(factory.TYPE_REPO)
        self.assertTrue(isinstance(manager, FakeManager))

        # Test Reset
        factory.reset()
        manager = factory.get_manager(factory.TYPE_REPO)
        self.assertTrue(isinstance(manager, RepoManager))
Beispiel #4
0
    def test_register_and_reset(self):
        """
        Tests that registering a new class and resetting properly affects the
        class mappings.
        """

        # Setup
        class FakeManager:
            pass

        factory.register_manager(factory.TYPE_REPO, FakeManager)

        # Test Register
        manager = factory.get_manager(factory.TYPE_REPO)
        self.assertTrue(isinstance(manager, FakeManager))

        # Test Reset
        factory.reset()
        manager = factory.get_manager(factory.TYPE_REPO)
        self.assertTrue(isinstance(manager, RepoManager))
Beispiel #5
0
    def test_get_manager(self):
        """
        Tests retrieving a manager instance for a valid manager mapping.
        """

        # Setup
        factory.initialize()

        # Test
        manager = factory.get_manager(factory.TYPE_REPO)

        # Verify
        self.assertTrue(manager is not None)
        self.assertTrue(isinstance(manager, RepoManager))
Beispiel #6
0
    def test_get_manager(self):
        """
        Tests retrieving a manager instance for a valid manager mapping.
        """

        # Setup
        factory.initialize()

        # Test
        manager = factory.get_manager(factory.TYPE_REPO)

        # Verify
        self.assertTrue(manager is not None)
        self.assertTrue(isinstance(manager, RepoManager))