Example #1
0
    def test_register_Nones(self):
        from repoze.component import provides

        class Two(object):
            provides("two")

        class One(Two):
            provides("one")

        class B(object):
            provides("b")

        class A(B):
            provides("a")

        instance1 = One()
        provides(instance1, "i")

        instance2 = A()
        provides(instance2, "i")

        registry = self._makeOne()
        registry.register("foo", "somevalue", None, None)

        result = registry.resolve("foo", instance1, instance2)
        self.assertEqual(result, "somevalue")
Example #2
0
    def test_register_Nones(self):
        from repoze.component import provides

        class Two(object):
            provides('two')

        class One(Two):
            provides('one')

        class B(object):
            provides('b')

        class A(B):
            provides('a')

        instance1 = One()
        provides(instance1, 'i')

        instance2 = A()
        provides(instance2, 'i')

        registry = self._makeOne()
        registry.register('foo', 'somevalue', None, None)

        result = registry.resolve('foo', instance1, instance2)
        self.assertEqual(result, 'somevalue')
Example #3
0
    def test_register_and_resolve_all(self):
        from repoze.component.registry import ALL
        from repoze.component import provides

        deckard = OSDeckard(None)
        provides(deckard, "deckard")

        registry = self._makeRegistry()
        result = registry.resolve("bladerunner", None, deckard, name=ALL)
        self.assertEqual(result, ["deckardvalue"])
        registry.register("bladerunner", "deckardvalue2", None, "deckard", name="another")
        result = registry.resolve("bladerunner", None, deckard, name=ALL)
        self.assertEqual(result, ["deckardvalue", "deckardvalue2"])
Example #4
0
    def test_register_and_resolve_all(self):
        from repoze.component.registry import ALL
        from repoze.component import provides

        deckard = OSDeckard(None)
        provides(deckard, 'deckard')

        registry = self._makeRegistry()
        result = registry.resolve('bladerunner', None, deckard, name=ALL)
        self.assertEqual(result, ['deckardvalue'])
        registry.register('bladerunner',
                          'deckardvalue2',
                          None,
                          'deckard',
                          name='another')
        result = registry.resolve('bladerunner', None, deckard, name=ALL)
        self.assertEqual(result, ['deckardvalue', 'deckardvalue2'])
Example #5
0
 class Foo(object):
     provides('a', 'b')
Example #6
0
 class Foo:
     provides('a', 'b')
Example #7
0
 class A(B):
     provides('a')
Example #8
0
 class B(object):
     provides('b')
Example #9
0
 class One(Two):
     provides('one')
Example #10
0
class OSLuckman:
    provides('luckman')

    def __init__(self, context):
        self.context = context
Example #11
0
    def test_register_and_resolve_oldstyle_instances_withdict(self):
        registry = self._makeRegistry()
        resolve = registry.resolve
        eq = self.assertEqual
        from repoze.component import provides

        deckard = OSDeckard(None)
        provides(deckard, "deckard")

        inheritsdeckard = OSInheritsDeckard(None)
        provides(inheritsdeckard, "inhherits")

        luckman = OSLuckman(None)
        provides(luckman, "luckman")

        barris = OSBarris(None)
        provides(barris, "barris")

        inheritsbarris = OSInheritsBarris(None)
        provides(inheritsbarris, "inherits")

        deckardbarris = OSDeckardBarris(None, None)
        provides(deckardbarris, "deckard", "barris")

        eq(resolve("bladerunner", None, deckard), "deckardvalue")
        eq(resolve("bladerunner", None, inheritsdeckard), "deckardvalue")
        eq(resolve("friend", luckman, name="name"), "luckmanvalue")
        eq(resolve("fight", barris, luckman), "barrisluckmanvalue")
        eq(resolve("fight", inheritsbarris, luckman), "barrisluckmanvalue")
        eq(resolve("fight", deckardbarris, luckman), "barrisluckmanvalue")
        eq(resolve("bladerunner", None, deckardbarris), "deckardvalue")
        eq(resolve("friend", luckman, default=None), None)
        eq(resolve("bladerunner", deckard, luckman, default=None), None)
        eq(resolve("bladerunner", luckman, deckard), "deckardvalue")
        eq(resolve("bladerunner", barris, deckard), "deckardvalue")
        eq(resolve("bladerunner", None, None, default=None), None)
Example #12
0
class OSInheritsBarris(OSBarris):
    provides('inherits')

    def __init__(self, context):
        self.context = context
Example #13
0
    def test_register_and_resolve_oldstyle_instances_withdict(self):
        registry = self._makeRegistry()
        resolve = registry.resolve
        eq = self.assertEqual
        from repoze.component import provides

        deckard = OSDeckard(None)
        provides(deckard, 'deckard')

        inheritsdeckard = OSInheritsDeckard(None)
        provides(inheritsdeckard, 'inhherits')

        luckman = OSLuckman(None)
        provides(luckman, 'luckman')

        barris = OSBarris(None)
        provides(barris, 'barris')

        inheritsbarris = OSInheritsBarris(None)
        provides(inheritsbarris, 'inherits')

        deckardbarris = OSDeckardBarris(None, None)
        provides(deckardbarris, 'deckard', 'barris')

        eq(resolve('bladerunner', None, deckard), 'deckardvalue')
        eq(resolve('bladerunner', None, inheritsdeckard), 'deckardvalue')
        eq(resolve('friend', luckman, name='name'), 'luckmanvalue')
        eq(resolve('fight', barris, luckman), 'barrisluckmanvalue')
        eq(resolve('fight', inheritsbarris, luckman), 'barrisluckmanvalue')
        eq(resolve('fight', deckardbarris, luckman), 'barrisluckmanvalue')
        eq(resolve('bladerunner', None, deckardbarris), 'deckardvalue')
        eq(resolve('friend', luckman, default=None), None)
        eq(resolve('bladerunner', deckard, luckman, default=None), None)
        eq(resolve('bladerunner', luckman, deckard), 'deckardvalue')
        eq(resolve('bladerunner', barris, deckard), 'deckardvalue')
        eq(resolve('bladerunner', None, None, default=None), None)
Example #14
0
class OSInheritsDeckard(OSDeckard):
    provides('inherits')

    def __init__(self, context):
        self.context = context
Example #15
0
class OSDeckardBarris:
    provides('deckard', 'barris')

    def __init__(self, context1, context2):
        self.context1 = context1
        self.context2 = context2
Example #16
0
class OSBarris:
    provides('barris')

    def __init__(self, context):
        self.context = context
Example #17
0
 def _callFUT(self, obj, *types):
     from repoze.component import provides
     provides(obj, *types)
Example #18
0
class Barris(object):
    provides('barris')

    def __init__(self, context):
        self.context = context
Example #19
0
 class Foo(object):
     provides('abc', 'def')
Example #20
0
class Luckman(object):
    provides('luckman')

    def __init__(self, context):
        self.context = context
Example #21
0
 class Two(object):
     provides('two')
Example #22
0
class OSDeckard:
    provides('deckard')

    def __init__(self, context):
        self.context = context
Example #23
0
    def _callFUT(self, obj, *types):
        from repoze.component import provides

        provides(obj, *types)
Example #24
0
class Deckard(object):
    provides('deckard')

    def __init__(self, context):
        self.context = context