예제 #1
0
def test_complexstruct_nested_rendering():
    obj = [{
        'foo1': (Property('foo'), Secret('bar')),
        'bar1': {
            'foo': 'foo',
            'bar': Property('bar')
        }
    }, {
        'foo2': (Property('foo'), Secret('bar')),
        'bar2': {
            'foo': 'foo',
            'bar': Property('bar')
        }
    }]
    expected = [{
        'foo1': (None, None),
        'bar1': {
            'foo': 'foo',
            'bar': None
        }
    }, {
        'foo2': (None, None),
        'bar2': {
            'foo': 'foo',
            'bar': None
        }
    }]

    @defer.inlineCallbacks
    def callback(irenderable):
        return (yield None)

    assert (yield recursiverender(obj, callback)) == expected
예제 #2
0
def test_nonrecursive_rendering():
    # recursiverender(<object>, <callback>)
    obj = Property('foo')

    @defer.inlineCallbacks
    def callback(irenderable):
        return (yield irenderable)

    assert (yield recursiverender(obj, callback)) is obj
예제 #3
0
def test_simplestruct_nested_rendering(obj):
    was_called = False

    @defer.inlineCallbacks
    def callback(irenderable):
        nonlocal was_called
        was_called = True
        assert irenderable == Property("foo")
        return (yield irenderable)

    assert (yield recursiverender(obj, callback)) == obj
    assert was_called
예제 #4
0
def test_recursiverendering_dont_call_callback_if_not_renderable():
    obj = object()

    was_called = False

    @defer.inlineCallbacks
    def callback(irenderable):
        nonlocal was_called
        was_called = True
        yield None

    yield recursiverender(obj, callback)

    assert not was_called
예제 #5
0
def test_recursiverendering_calls_callback_if_renderable():
    obj = Property('foo')

    was_called = False

    @defer.inlineCallbacks
    def callback(irenderable):
        nonlocal was_called
        was_called = True
        yield None

    yield recursiverender(obj, callback)

    assert was_called
예제 #6
0
    def getSchedulersAndProperties(self):
        def callback(obj):
            return obj.getRenderingFor(self.build.properties)

        result = yield recursiverender(list(self.processor(self)), callback)
        return result