"""Objects catalog unittests."""

import unittest2 as unittest

from objects.catalog import AbstractCatalog

from objects.providers import Object
from objects.providers import Value

from objects.errors import Error


class CatalogTests(unittest.TestCase):

    """Catalog test cases."""

    class Catalog(AbstractCatalog):

        """Test catalog."""

        obj = Object(object())
        another_obj = Object(object())

    def test_get_used(self):
        """Test retrieving used provider."""
        catalog = self.Catalog(self.Catalog.obj)
        self.assertIsInstance(catalog.obj(), object)

    def test_get_unused(self):
        """Test retrieving unused provider."""
        catalog = self.Catalog()
        self.assertRaises(Error, getattr, catalog, 'obj')

    def test_all_providers(self):
        """Test getting of all catalog providers."""
        all_providers = self.Catalog.all_providers()
        all_providers_dict = dict(all_providers)

        self.assertIsInstance(all_providers, set)
        self.assertTrue(len(all_providers) == 2)

        self.assertIn('obj', all_providers_dict)
        self.assertIn(self.Catalog.obj, all_providers_dict.values())

        self.assertIn('another_obj', all_providers_dict)
        self.assertIn(self.Catalog.another_obj, all_providers_dict.values())

    def test_all_providers_by_type(self):
        """Test getting of all catalog providers of specific type."""
        self.assertTrue(len(self.Catalog.all_providers(Object)) == 2)
        self.assertTrue(len(self.Catalog.all_providers(Value)) == 0)

@@ -100,16 +100,54 @@
 tCatalog
+%0Afrom objects.catalog import overrides
 %0A%0Afrom o
@@ -1599,8 +1599,387 @@
 ) == 0)%0A
+%0A    def test_overriding(self):%0A        %22%22%22Test catalog overriding with another catalog.%22%22%22%0A        @overrides(self.Catalog)%0A        class OverridingCatalog(self.Catalog):%0A%0A            %22%22%22Overriding catalog.%22%22%22%0A%0A            obj = Value(1)%0A            another_obj = Value(2)%0A%0A        self.assertEqual(self.Catalog.obj(), 1)%0A        self.assertEqual(self.Catalog.another_obj(), 2)%0A

Add tests for catalog.overrides decorator