Add tests for catalog.overrides decorator

This commit is contained in:
Roman Mogilatov 2015-03-16 17:31:16 +02:00
parent d93abe8554
commit 22055c3f63

View File

@ -3,6 +3,7 @@
import unittest2 as unittest import unittest2 as unittest
from objects.catalog import AbstractCatalog from objects.catalog import AbstractCatalog
from objects.catalog import overrides
from objects.providers import Object from objects.providers import Object
from objects.providers import Value from objects.providers import Value
@ -49,3 +50,16 @@ class CatalogTests(unittest.TestCase):
"""Test getting of all catalog providers of specific type.""" """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(Object)) == 2)
self.assertTrue(len(self.Catalog.all_providers(Value)) == 0) self.assertTrue(len(self.Catalog.all_providers(Value)) == 0)
def test_overriding(self):
"""Test catalog overriding with another catalog."""
@overrides(self.Catalog)
class OverridingCatalog(self.Catalog):
"""Overriding catalog."""
obj = Value(1)
another_obj = Value(2)
self.assertEqual(self.Catalog.obj(), 1)
self.assertEqual(self.Catalog.another_obj(), 2)