当前位置: 首页>>代码示例>>Python>>正文


Python helpers.verify_table_html函数代码示例

本文整理汇总了Python中tests.helpers.verify_table_html函数的典型用法代码示例。如果您正苦于以下问题:Python verify_table_html函数的具体用法?Python verify_table_html怎么用?Python verify_table_html使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了verify_table_html函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_show_lambda

def test_show_lambda():
    def show_callable(table, column):
        assert isinstance(table, TestTable)
        assert column.name == "bar"
        return False

    class TestTable(NoSortTable):
        foo = Column()
        bar = Column.icon("foo", show=show_callable)

    data = [Struct(foo="foo", bar="bar")]

    verify_table_html(
        table=TestTable(data=data),
        expected_html="""
    <table class="listview">
        <thead>
            <tr><th class="first_column subheader"> Foo </th></tr>
        </thead>
        <tbody>
            <tr class="row1">
                <td> foo </td>
            </tr>
        </tbody>
    </table>""",
    )
开发者ID:TriOptima,项目名称:tri.table,代码行数:26,代码来源:test_tri_table.py

示例2: test_attr

def test_attr():
    class TestTable(NoSortTable):
        foo = Column()
        bar = Column(attr="foo")

    data = [Struct(foo="foo")]

    verify_table_html(
        table=TestTable(data=data),
        expected_html="""
    <table class="listview">
        <thead>
            <tr>
                <th class="first_column subheader"> Foo </th>
                <th class="first_column subheader"> Bar </th>
            </tr>
        </thead>
        <tbody>
            <tr class="row1">
                <td> foo </td>
                <td> foo </td>
            </tr>
        </tbody>
    </table>""",
    )
开发者ID:TriOptima,项目名称:tri.table,代码行数:25,代码来源:test_tri_table.py

示例3: test_link

def test_link():
    class TestTable(NoSortTable):
        foo = Column.link(cell__url="https://whereever", cell__url_title="whatever")
        bar = Column.link(cell__value="bar", cell__url_title=lambda **_: "url_title_goes_here")

    data = [Struct(foo="foo", bar=Struct(get_absolute_url=lambda: "/get/absolute/url/result"))]

    verify_table_html(
        table=TestTable(data=data),
        expected_html="""
        <table class="listview">
            <thead>
                <tr>
                    <th class="first_column subheader"> Foo </th>
                    <th class="first_column subheader"> Bar </th>
                </tr>
            </thead>
            <tbody>
                <tr class="row1">
                    <td> <a href="https://whereever" title="whatever"> foo </a> </td>
                    <td> <a href="/get/absolute/url/result" title="url_title_goes_here"> bar </a> </td>
                </tr>
            </tbody>
        </table>""",
    )
开发者ID:TriOptima,项目名称:tri.table,代码行数:25,代码来源:test_tri_table.py

示例4: test_django_table_pagination

def test_django_table_pagination():

    for x in xrange(30):
        Foo(a=x, b="foo").save()

    class TestTable(Table):
        a = Column.number(sortable=False)  # turn off sorting to not get the link with random query params
        b = Column(show=False)  # should still be able to filter on this though!

    verify_table_html(TestTable(data=Foo.objects.all()),
                      query=dict(page_size=2, page=2, query='b="foo"'),
                      expected_html="""
        <table class="listview">
            <thead>
                <tr>
                    <th class="first_column subheader"> A </th>
                </tr>
            </thead>
            <tbody>
                <tr class="row1" data-pk="3">
                    <td class="rj"> 2 </td>
                </tr>
                <tr class="row2" data-pk="4">
                    <td class="rj"> 3 </td>
                </tr>
            </tbody>
        </table>""")
开发者ID:pombredanne,项目名称:tri.table,代码行数:27,代码来源:test_tri_table.py

示例5: test_django_table

def test_django_table():

    Foo(a=17, b="Hej").save()
    Foo(a=42, b="Hopp").save()

    class TestTable(Table):
        a = Column.number()
        b = Column()

    verify_table_html(TestTable(Foo.objects.all()), """
        <table class="listview">
            <thead>
                <tr>
                    <th class="subheader first_column">
                        <a href="?order=a"> A </a>
                    </th>
                    <th class="subheader first_column">
                        <a href="?order=b"> B </a>
                    </th>
                </tr>
            </thead>
            <tr class="row1" data-pk="1">
                <td class="rj"> 17 </td>
                <td> Hej </td>
            </tr>
            <tr class="row2" data-pk="2">
                <td class="rj"> 42 </td>
                <td> Hopp </td>
            </tr>
        </table>""")
开发者ID:schyssler,项目名称:tri.tables,代码行数:30,代码来源:test_tri_tables.py

示例6: test_attrs

def test_attrs():
    class TestTable(NoSortTable):
        class Meta:
            attrs = {
                'class': 'classy',
                'foo': 'bar'
            }
            row_attrs = {
                'class': 'classier',
                'foo': lambda row: "barier"
            }

        yada = Column()

    verify_table_html(TestTable([(1,), (2,)]), """
        <table class="classy" foo="bar">
            <thead>
                <tr>
                  <th class="subheader first_column"> Yada </th>
                </tr>
            </thead>
                <tr class="row1 classier" foo="barier">
                    <td> 1 </td>
                </tr>
                <tr class="row2 classier" foo="barier">
                    <td> 2 </td>
                </tr>
        </table>""")
开发者ID:schyssler,项目名称:tri.tables,代码行数:28,代码来源:test_tri_tables.py

示例7: test_auto_rowspan_and_render_twice

def test_auto_rowspan_and_render_twice():
    class TestTable(NoSortTable):
        foo = Column(auto_rowspan=True)

    data = [
        Struct(foo=1),
        Struct(foo=1),
        Struct(foo=2),
        Struct(foo=2),
    ]

    expected = """
        <table class="listview">
            <thead>
                <tr><th class="first_column subheader"> Foo </th></tr>
            </thead>
            <tbody>
                <tr class="row1">
                    <td rowspan="2"> 1 </td>
                </tr>
                <tr class="row2">
                    <td style="display: none"> 1 </td>
                </tr>
                <tr class="row1">
                    <td rowspan="2"> 2 </td>
                </tr>
                <tr class="row2">
                    <td style="display: none"> 2 </td>
                </tr>
            </tbody>
        </table>"""

    t = TestTable(data=data)
    verify_table_html(t, expected)
    verify_table_html(t, expected)
开发者ID:pombredanne,项目名称:tri.table,代码行数:35,代码来源:test_tri_table.py

示例8: test_render_impl

def test_render_impl(table):

    verify_table_html(table, """
        <table class="listview" id="table_id">
            <thead>
                <tr>
                    <th class="first_column subheader">
                        <a href="?order=foo"> Foo </a>
                    </th>
                    <th class="first_column subheader">
                        <a href="?order=bar"> Bar </a>
                    </th>
                </tr>
            </thead>
            <tbody>
                <tr class="row1">
                    <td> Hello </td>
                    <td class="rj"> 17 </td>
                </tr>
                <tr class="row2">
                    <td> &lt;evil/&gt; &amp; </td>
                    <td class="rj"> 42 </td>
                </tr>
            </tbody>
        </table>""")
开发者ID:pombredanne,项目名称:tri.table,代码行数:25,代码来源:test_tri_table.py

示例9: test_cell_template

def test_cell_template():
    def explode(**_):
        assert False

    class TestTable(NoSortTable):
        foo = Column(
            cell__template="test_cell_template.html", cell__format=explode, cell__url=explode, cell__url_title=explode
        )

    data = [Struct(foo="sentinel")]

    verify_table_html(
        table=TestTable(data=data),
        expected_html="""
        <table class="listview">
            <thead>
                <tr><th class="first_column subheader"> Foo </th></tr>
            </thead>
            <tbody>
                <tr class="row1">
                    Custom rendered: sentinel
                </tr>
            </tbody>
        </table>""",
    )
开发者ID:TriOptima,项目名称:tri.table,代码行数:25,代码来源:test_tri_table.py

示例10: test_attrs

def test_attrs():
    class TestTable(NoSortTable):
        class Meta:
            attrs = {
                'class': 'classy',
                'foo': lambda table: 'bar'
            }
            row__attrs = {
                'class': 'classier',
                'foo': lambda table: "barier"
            }

        yada = Column()

    verify_table_html(TestTable(data=[Struct(yada=1), Struct(yada=2)]), """
        <table class="classy" foo="bar">
            <thead>
                <tr>
                  <th class="first_column subheader"> Yada </th>
                </tr>
            </thead>
            <tbody>
                <tr class="classier row1" foo="barier">
                    <td> 1 </td>
                </tr>
                <tr class="classier row2" foo="barier">
                    <td> 2 </td>
                </tr>
            </tbody>
        </table>""", find=dict(class_='classy'))
开发者ID:pombredanne,项目名称:tri.table,代码行数:30,代码来源:test_tri_table.py

示例11: test_attrs_new_syntax

def test_attrs_new_syntax():
    class TestTable(NoSortTable):
        class Meta:
            attrs__class__classy = True
            attrs__foo = lambda table: 'bar'

            row__attrs__class__classier = True
            row__attrs__foo = lambda table: "barier"

        yada = Column()

    verify_table_html(table=TestTable(data=[Struct(yada=1), Struct(yada=2)]), expected_html="""
        <table class="classy listview" foo="bar">
            <thead>
                <tr>
                  <th class="first_column subheader"> Yada </th>
                </tr>
            </thead>
            <tbody>
                <tr class="classier row1" foo="barier">
                    <td> 1 </td>
                </tr>
                <tr class="classier row2" foo="barier">
                    <td> 2 </td>
                </tr>
            </tbody>
        </table>""")
开发者ID:jlubcke,项目名称:tri.table,代码行数:27,代码来源:test_tri_table.py

示例12: test_auto_rowspan

def test_auto_rowspan():
    class TestTable(NoSortTable):
        foo = Column(auto_rowspan=True)

    data = [
        Struct(foo=1),
        Struct(foo=1),
        Struct(foo=2),
        Struct(foo=2),
    ]

    verify_table_html(TestTable(data), """
        <table class="listview">
            <thead>
                <tr><th class="subheader first_column"> Foo </th></tr>
            </thead>
            <tr class="row1">
                <td rowspan="2"> 1 </td>
            </tr>
            <tr class="row2">
                <td style="display: none"> 1 </td>
            </tr>
            <tr class="row1">
                <td rowspan="2"> 2 </td>
            </tr>
            <tr class="row2">
                <td style="display: none"> 2 </td>
            </tr>
        </table>""")
开发者ID:schyssler,项目名称:tri.tables,代码行数:29,代码来源:test_tri_tables.py

示例13: test_row_template

def test_row_template():
    class TestTable(NoSortTable):
        foo = Column()
        bar = Column()

        class Meta:
            row__template = lambda table: 'test_table_row.html'

    data = [Struct(foo="sentinel", bar="schmentinel")]

    verify_table_html(table=TestTable(data=data), expected_html="""
        <table class="listview">
            <thead>
                <tr>
                  <th class="first_column subheader"> Foo </th>
                  <th class="first_column subheader"> Bar </th>
                </tr>
            </thead>
            <tbody>

             All columns:
             <td> sentinel </td>
             <td> schmentinel </td>

             One by name:
              <td> sentinel </td>
            </tbody>
        </table>""")
开发者ID:jlubcke,项目名称:tri.table,代码行数:28,代码来源:test_tri_table.py

示例14: test_attrs

def test_attrs():
    class TestTable(NoSortTable):
        class Meta:
            attrs = {
                'class': 'classy',
                'foo': lambda table: 'bar'
            }
            row__attrs = {
                'class': 'classier',
                'foo': lambda table, row: "barier"
            }

        yada = Column()

    verify_table_html(table=TestTable(data=[Struct(yada=1), Struct(yada=2)]), expected_html="""
        <table class="classy listview" foo="bar">
            <thead>
                <tr>
                  <th class="first_column subheader"> Yada </th>
                </tr>
            </thead>
            <tbody>
                <tr class="classier row1" foo="barier">
                    <td> 1 </td>
                </tr>
                <tr class="classier row2" foo="barier">
                    <td> 2 </td>
                </tr>
            </tbody>
        </table>""")
开发者ID:jlubcke,项目名称:tri.table,代码行数:30,代码来源:test_tri_table.py

示例15: test_css_class

def test_css_class():
    class TestTable(NoSortTable):
        foo = Column(attrs__class__some_class=True)
        legacy_foo = Column(css_class={"some_other_class"})
        legacy_bar = Column(cell__attrs={'class': 'foo'},
                            cell__attrs__class__bar=True)

    data = [Struct(foo="foo", legacy_foo="foo", legacy_bar="bar")]

    verify_table_html(table=TestTable(data=data), expected_html="""
    <table class="listview">
        <thead>
            <tr>
                <th class="first_column some_class subheader"> Foo </th>
                <th class="first_column some_other_class subheader"> Legacy foo </th>
                <th class="first_column subheader"> Legacy bar </th>
            </tr>
        </thead>
        <tbody>
            <tr class="row1">
                <td> foo </td>
                <td> foo </td>
                <td class="bar foo"> bar </td>
            </tr>
        </tbody>
    </table>""")
开发者ID:jlubcke,项目名称:tri.table,代码行数:26,代码来源:test_tri_table.py


注:本文中的tests.helpers.verify_table_html函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。