示例#1
0
def test_unicode_ajax_response(pyramid_req):
    """Check if the rendering process generates all a valid utf-8 encoded response
    """

    # Create a Transaction with an assigned root_node.
    page = Page(None, pyramid_req)
    page.request.is_xhr = True
    page.page_request.params = {"q": []}
    transaction = page.transaction
    transaction['components_assigned'] = True
    transaction.set_component(
        'root_node', {
            'cid': 'root_node',
            'slot': None,
            'config': {},
            'class': (ComponentContainerBase, {}, ('root_node', None))
        })

    page.handle_transaction()

    # Generate a response with a unicode string.
    page.root_node.add_js_response(u'console.log("ää");')

    # Redraw and handle_ajax_events, so that all necessary output will be generated.
    page.root_node.redraw()

    page.handle_ajax_events()

    assert True not in [c.is_rendered for c in page.get_active_components()]

    out = page.render()
    assert u'console.log("ää");' in out
    out.encode('utf-8')
示例#2
0
def test_unicode_ajax_response(pyramid_req):
    """Check if the rendering process generates all a valid utf-8 encoded response
    """

    # Create a Transaction with an assigned root_node.
    page = Page(None, pyramid_req)
    page.request.is_xhr = True
    page.page_request.params = {"q": []}
    transaction = page.transaction
    transaction['components_assigned'] = True
    transaction.set_component('root_node',
                              {'cid': 'root_node',
                               'slot': None,
                               'config': {},
                               'class': (ComponentContainerBase,
                                         {},
                                         ('root_node', None))})

    page.handle_transaction()

    # Generate a response with a unicode string.
    page.root_node.add_js_response(u'console.log("ää");')

    # Redraw and handle_ajax_events, so that all necessary output will be generated.
    page.root_node.redraw()

    page.handle_ajax_events()

    assert True not in [c.is_rendered for c in page.get_active_components()]

    out = page.render()
    assert u'console.log("ää");' in out
    out.encode('utf-8')
示例#3
0
def test_component_rendering_ajax(pyramid_req):
    """Check if the rendering process generates all required AJAX scripts.
    """

    # Create a Transaction with an assigned root_node.
    page = Page(pyramid_req)
    page.request.is_xhr = True
    page.page_request.params = {"q": []}
    transaction = page.transaction
    transaction['components_assigned'] = True
    transaction.set_component('root_node',
                              {'cid': 'root_node',
                               'slot': None,
                               'config': {},
                               'class': (ComponentContainerBase,
                                         {},
                                         ('root_node', None))})

    page.handle_transaction()

    base_components = 10
    leaf_components = 200

    # Generate a nice round 210 child components.
    page.root_node.add_component(ComponentContainerBase(cid='child_node_0'))
    for i in range(0, base_components):
        getattr(page, 'child_node_%s' % i) \
            .add_component(ComponentContainerBase(cid='child_node_%s' % (i + 1)))
        for x in range(0, leaf_components):
            getattr(page,
                    'child_node_%s' % (i + 1)) \
                .add_component(ComponentContainerBase(cid='child_node_%s_%s' % (i + 1, x)))

    # Redraw and handle_ajax_events, so that all necessary output will be generated.
    page.root_node.redraw()

    page.handle_ajax_events()

    assert True not in [c.is_rendered for c in page.get_active_components()]

    # start_time = time.time()
    out = page.render()
    # print base_components, leaf_components, int((time.time() - start_time) * 1000000)

    # Checking set_component_info calls required to tell EPFLs JS what the component is capable of.
    for i in range(0, base_components):
        assert ('epfl.set_component_info(\\"child_node_%s\\", \\"handle\\", [\'change\', \'reinitialize\', '
                '\'set_row\']);' %
                (i + 1)) in out, "Missing set component info for child_node_%s" % (i + 1)
        out = out.replace('epfl.set_component_info("child_node_%s", "handle", [\'set_row\']);' % (i + 1), '')
        for x in range(0, leaf_components):
            assert ('epfl.set_component_info(\\"child_node_%s_%s\\", \\"handle\\", [\'change\', \'reinitialize\', '
                    '\'set_row\']);' % (i + 1, x)) in out
            out = out.replace('epfl.set_component_info("child_node_%s_%s", "handle", [\'change\', \'set_row\']);' %
                              (i + 1, x), '')
    assert 'epfl.set_component_info(\\"child_node_0\\", \\"handle\\", [\'change\', \'reinitialize\', \'set_row\']);' \
           'epfl.set_component_info(\\"root_node\\", \\"handle\\", [\'change\', \'reinitialize\', \'set_row\']);' in out
示例#4
0
def test_component_rendering_ajax(pyramid_req):
    """Check if the rendering process generates all required AJAX scripts.
    """

    # Create a Transaction with an assigned root_node.
    page = Page(None, pyramid_req)
    page.request.is_xhr = True
    page.page_request.params = {"q": []}
    transaction = page.transaction
    transaction['components_assigned'] = True
    transaction.set_component(
        'root_node', {
            'cid': 'root_node',
            'slot': None,
            'config': {},
            'class': (ComponentContainerBase, {}, ('root_node', None))
        })

    page.handle_transaction()

    base_components = 10
    leaf_components = 200

    # Generate a nice round 210 child components.
    page.root_node.add_component(ComponentContainerBase(cid='child_node_0'))
    for i in range(0, base_components):
        getattr(page, 'child_node_%s' % i) \
            .add_component(ComponentContainerBase(cid='child_node_%s' % (i + 1)))
        for x in range(0, leaf_components):
            getattr(page,
                    'child_node_%s' % (i + 1)) \
                .add_component(ComponentContainerBase(cid='child_node_%s_%s' % (i + 1, x)))

    # Redraw and handle_ajax_events, so that all necessary output will be generated.
    page.root_node.redraw()

    page.handle_ajax_events()

    assert True not in [c.is_rendered for c in page.get_active_components()]

    # start_time = time.time()
    out = page.render()
示例#5
0
def test_component_rendering_ajax(pyramid_req):
    """Check if the rendering process generates all required AJAX scripts.
    """

    # Create a Transaction with an assigned root_node.
    page = Page(None, pyramid_req)
    page.request.is_xhr = True
    page.page_request.params = {"q": []}
    transaction = page.transaction
    transaction['components_assigned'] = True
    transaction.set_component('root_node',
                              {'cid': 'root_node',
                               'slot': None,
                               'config': {},
                               'class': (ComponentContainerBase,
                                         {},
                                         ('root_node', None))})

    page.handle_transaction()

    base_components = 10
    leaf_components = 200

    # Generate a nice round 210 child components.
    page.root_node.add_component(ComponentContainerBase(cid='child_node_0'))
    for i in range(0, base_components):
        getattr(page, 'child_node_%s' % i) \
            .add_component(ComponentContainerBase(cid='child_node_%s' % (i + 1)))
        for x in range(0, leaf_components):
            getattr(page,
                    'child_node_%s' % (i + 1)) \
                .add_component(ComponentContainerBase(cid='child_node_%s_%s' % (i + 1, x)))

    # Redraw and handle_ajax_events, so that all necessary output will be generated.
    page.root_node.redraw()

    page.handle_ajax_events()

    assert True not in [c.is_rendered for c in page.get_active_components()]

    # start_time = time.time()
    out = page.render()