• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python helpers.verify_table_html函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: test_cell_lambda

def test_cell_lambda():
    class TestTable(NoSortTable):
        sentinel1 = "sentinel1"

        sentinel2 = Column(
            cell__value=lambda table, column, row, **_: "%s %s %s" % (table.sentinel1, column.name, row.sentinel3)
        )

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

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


示例17: test_dict_data

def test_dict_data():
    class TestTable(Table):
        class Meta:
            sortable = False
        a = Column()
        b = Column()
        c = Column()

    data = [{'a': 'a', 'b': 'b', 'c': 'c'}]

    verify_table_html(TestTable(data), """
        <table class="listview">
             <thead>
                 <tr>
                     <th class="subheader first_column"> A </th>
                     <th class="subheader first_column"> B </th>
                     <th class="subheader first_column"> C </th>
                 </tr>
             </thead>
             <tr class="row1">
                 <td> a </td>
                 <td> b </td>
                 <td> c </td>
             </tr>
         </table>""")
开发者ID:schyssler,项目名称:tri.tables,代码行数:25,代码来源:test_tri_tables.py


示例18: test_sort_list_bad_parameter

def test_sort_list_bad_parameter():

    class TestTable(Table):
        foo = Column()
        bar = Column.number(sort_key='bar')

    data = [Struct(foo='b', bar=2),
            Struct(foo='a', bar=1)]

    verify_table_html(table=TestTable(data=data),
                      query=dict(order='barfology'),
                      expected_html="""\
      <table class="listview">
        <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> b </td>
            <td class="rj"> 2 </td>
          </tr>
          <tr class="row2">
            <td> a </td>
            <td class="rj"> 1 </td>
          </tr>
        </tbody>
      </table>
    """)
开发者ID:TriOptima,项目名称:tri.table,代码行数:35,代码来源:test_sort.py


示例19: test_django_table

def test_django_table():

    f1 = Foo.objects.create(a=17, b="Hej")
    f2 = Foo.objects.create(a=42, b="Hopp")

    Bar(foo=f1, c=True).save()
    Bar(foo=f2, c=False).save()

    class TestTable(Table):
        foo__a = Column.number()
        foo__b = Column()
        foo = Column.choice_queryset(
            model=Foo,
            choices=lambda table, column, **_: Foo.objects.all(),
            query__show=True,
            bulk__show=True,
            query__gui__show=True,
        )

    t = TestTable(data=Bar.objects.all())

    t.prepare(RequestFactory().get("/", ""))

    assert list(t.bound_columns[-1].choices) == list(Foo.objects.all())
    assert list(t.bulk_form.fields[-1].choices) == list(Foo.objects.all())
    assert list(t.query_form.fields[-1].choices) == list(Foo.objects.all())

    verify_table_html(
        table=t,
        expected_html="""
        <table class="listview">
            <thead>
                <tr>
                    <th class="first_column subheader">
                        <a href="?order=foo__a"> A </a>
                    </th>
                    <th class="first_column subheader">
                        <a href="?order=foo__b"> B </a>
                    </th>
                    <th class="first_column subheader">
                        <a href="?order=foo"> Foo </a>
                    </th>
                </tr>
            </thead>
            <tbody>
                <tr class="row1" data-pk="1">
                    <td class="rj"> 17 </td>
                    <td> Hej </td>
                    <td> Foo(17, Hej) </td>

                </tr>
                <tr class="row2" data-pk="2">
                    <td class="rj"> 42 </td>
                    <td> Hopp </td>
                    <td> Foo(42, Hopp) </td>
                </tr>
            </tbody>
        </table>""",
    )
开发者ID:TriOptima,项目名称:tri.table,代码行数:59,代码来源:test_tri_table.py


示例20: test_output

def test_output():

    is_report = False

    class TestTable(Table):

        class Meta:
            attrs = {
                'class': 'listview',
                'id': 'table_id',
            }

        foo = Column()
        bar = Column.number()
        icon = Column.icon('history', is_report, group="group")
        edit = Column.edit(is_report, group="group")
        delete = Column.delete(is_report)

    data = [
        Struct(foo="Hello räksmörgås ><&>",
               bar=17,
               get_absolute_url=lambda: '/somewhere/'),
    ]

    verify_table_html(TestTable(data=data), """
        <table class="listview" id="table_id">
            <thead>
                <tr>
                    <th class="first_column superheader" colspan="1"> </th>
                    <th class="superheader" colspan="1"> </th>
                    <th class="superheader" colspan="2"> group </th>
                    <th class="superheader" colspan="1"> </th>
                </tr>
                <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>
                    <th class="first_column subheader thin"> </th>
                    <th class="subheader thin" title="Edit"> </th>
                    <th class="first_column subheader thin" title="Delete"> </th>
                </tr>
            </thead>
            <tbody>
                <tr class="row1">
                    <td> Hello räksmörgås &gt;&lt;&amp;&gt; </td>
                    <td class="rj"> 17 </td>
                    <td class="cj"> <i class="fa fa-lg fa-history"> </i> </td>
                    <td class="cj"> <a href="/somewhere/edit/"> <i class="fa fa-lg fa-pencil-square-o" title="Edit"> </i> </a> </td>
                    <td class="cj"> <a href="/somewhere/delete/"> <i class="fa fa-lg fa-trash-o" title="Delete"> </i> </a> </td>
                </tr>
            </tbody>
        </table>
        """)
开发者ID:pombredanne,项目名称:tri.table,代码行数:56,代码来源:test_tri_table.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python factory.create_git_repo函数代码示例发布时间:2022-05-27
下一篇:
Python helpers.tempdir函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap