本文整理汇总了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>""",
)
示例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>""",
)
示例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>""",
)
示例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>""")
示例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>""")
示例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>""")
示例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)
示例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> <evil/> & </td>
<td class="rj"> 42 </td>
</tr>
</tbody>
</table>""")
示例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>""",
)
示例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'))
示例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>""")
示例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>""")
示例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>""")
示例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>""")
示例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>""")