Skip to content

Commit

Permalink
Test for kajiki templates too as we provide them
Browse files Browse the repository at this point in the history
  • Loading branch information
amol- committed Jun 8, 2016
1 parent 9f77fba commit 4738464
Show file tree
Hide file tree
Showing 20 changed files with 29 additions and 22 deletions.
11 changes: 10 additions & 1 deletion tests/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class WidgetTest(_WidgetTest):
the first two since those are the only templates provided by tw2.forms
itself.
"""
engines = ['mako', 'jinja']
engines = ['mako', 'jinja', 'kajiki']


class TestInputField(WidgetTest):
Expand Down Expand Up @@ -154,6 +154,9 @@ def test_escape(self):
attrs = {'value': 'line 1<br />line 2', 'escape': False}
expected = '<span>line 1<br />line 2<input value="line 1<br />line 2" type="hidden"/></span>'
for engine in self._get_all_possible_engines():
if engine == 'kajiki':
# Kajiki has no support for escape: False
continue
yield (self._check_rendering_vs_expected,
engine, attrs, self.params, expected)

Expand All @@ -174,6 +177,9 @@ def test_escape(self):
attrs = {'text': 'line 1<br />line 2', 'escape': False}
expected = '<a href="">line 1<br />line 2</a>'
for engine in self._get_all_possible_engines():
if engine == 'kajiki':
# Kajiki has no support for escape: False
continue
yield (self._check_rendering_vs_expected,
engine, attrs, self.params, expected)

Expand Down Expand Up @@ -689,6 +695,9 @@ def test_escape(self):
attrs = {'text': 'line 1<br />line 2', 'escape': False}
expected = '<span>line 1<br />line 2</span>'
for engine in self._get_all_possible_engines():
if engine == 'kajiki':
# Kajiki has no support for escape: False
continue
yield (self._check_rendering_vs_expected,
engine, attrs, self.params, expected)

Expand Down
4 changes: 1 addition & 3 deletions tw2/forms/templates/datagrid.kajiki
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<table xmlns="http://www.w3.org/1999/xhtml"
xmlns:py="http://genshi.edgewall.org/"
py:attrs="w.attrs" cellpadding="0" cellspacing="1" border="0">
<table py:attrs="w.attrs" cellpadding="0" cellspacing="1" border="0">
<thead py:if="w.columns">
<tr>
<th py:for="i, col in enumerate(w.columns)"
Expand Down
2 changes: 1 addition & 1 deletion tw2/forms/templates/fieldset.kajiki
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<fieldset xmlns:py="http://genshi.edgewall.org/" py:attrs="w.attrs">
<fieldset py:attrs="w.attrs">
<legend py:content="w.legend" />
${w.child.display()}
</fieldset>
2 changes: 1 addition & 1 deletion tw2/forms/templates/form.kajiki
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<form xmlns:py="http://genshi.edgewall.org/" py:attrs="w.attrs">
<form py:attrs="w.attrs">
<span class="error" py:content="w.error_msg"/>
<div py:if="w.help_msg" class="help">
<p>
Expand Down
2 changes: 1 addition & 1 deletion tw2/forms/templates/grid_layout.kajiki
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<table xmlns:py="http://genshi.edgewall.org/" py:attrs="w.attrs">
<table py:attrs="w.attrs">
<tr><th py:for="col in w.children[0].children_non_hidden">$col.label</th></tr>
<py:for each="row in w.children">${row.display()}</py:for>
<tr class="error"><td colspan="${len(w.children)}" id="${w.compound_id}:error">
Expand Down
2 changes: 1 addition & 1 deletion tw2/forms/templates/input_field.kajiki
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<input xmlns:py="http://genshi.edgewall.org/" py:attrs="w.attrs"/>
<input py:attrs="w.attrs"/>
2 changes: 1 addition & 1 deletion tw2/forms/templates/label.kajiki
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<span xmlns:py="http://genshi.edgewall.org/" py:attrs="w.attrs" py:content="w.text" />
<span py:attrs="w.attrs" py:content="w.text" />
2 changes: 1 addition & 1 deletion tw2/forms/templates/label_field.kajiki
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<span xmlns:py="http://genshi.edgewall.org/">$w.value<input py:attrs="w.attrs"/></span>
<span>$w.value<input py:attrs="w.attrs"/></span>
2 changes: 1 addition & 1 deletion tw2/forms/templates/link_field.kajiki
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<a xmlns:py="http://genshi.edgewall.org/" py:attrs="w.attrs">$w.text</a>
<a py:attrs="w.attrs">$w.text</a>
2 changes: 1 addition & 1 deletion tw2/forms/templates/list_layout.kajiki
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<ul xmlns:py="http://genshi.edgewall.org/" py:attrs="w.attrs">
<ul py:attrs="w.attrs">
<py:for each="c in w.children_hidden">
${c.display()}
</py:for>
Expand Down
2 changes: 1 addition & 1 deletion tw2/forms/templates/postlabeled_input_field.kajiki
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<input xmlns:py="http://genshi.edgewall.org/" py:attrs="w.attrs"/> <label for="${w.compound_id}" py:attrs="w.text_attrs">$w.text</label>
<input py:attrs="w.attrs"/> <label for="${w.compound_id}" py:attrs="w.text_attrs">$w.text</label>
2 changes: 1 addition & 1 deletion tw2/forms/templates/row_layout.kajiki
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<tr xmlns:py="http://genshi.edgewall.org/" py:attrs="w.attrs">
<tr py:attrs="w.attrs">
<td py:for="c in w.children_non_hidden" id="${c.compound_id}:container">
${c.display()}
<py:if test="c.error_msg"><img src="${w.resources.error.link}" title="${c.error_msg}"/></py:if>
Expand Down
2 changes: 1 addition & 1 deletion tw2/forms/templates/select_field.kajiki
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<select xmlns:py="http://genshi.edgewall.org/" py:attrs="w.attrs">
<select py:attrs="w.attrs">
<optgroup py:for="group, options in w.grouped_options"
py:strip="not group"
label="${group}" >
Expand Down
2 changes: 1 addition & 1 deletion tw2/forms/templates/selection_list.kajiki
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<ul xmlns:py="http://genshi.edgewall.org/" py:attrs="w.attrs">
<ul py:attrs="w.attrs">
<li py:for="group, opts in w.grouped_options" py:strip="not group">
<div class="group_header" py:if="group">$group</div>
<ul py:strip="not group">
Expand Down
2 changes: 1 addition & 1 deletion tw2/forms/templates/selection_table.kajiki
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<table xmlns:py="http://genshi.edgewall.org/" py:attrs="w.attrs" >
<table py:attrs="w.attrs" >
<tbody>
<tr py:for="row in w.options_rows">
<td py:for="attrs, desc in row">
Expand Down
2 changes: 1 addition & 1 deletion tw2/forms/templates/separated_selection_table.kajiki
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<table xmlns:py="http://genshi.edgewall.org/" py:attrs="w.attrs">
<table py:attrs="w.attrs">
<tr py:for="attrs, desc in w.options">
<td><input py:attrs="attrs" /></td>
<td><label for="${attrs['id']}" py:content="desc" /></td>
Expand Down
2 changes: 1 addition & 1 deletion tw2/forms/templates/spacer.kajiki
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<div xmlns:py="http://genshi.edgewall.org/">&nbsp;</div>
<div>&nbsp;</div>
2 changes: 1 addition & 1 deletion tw2/forms/templates/table_layout.kajiki
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<table xmlns:py="http://genshi.edgewall.org/" py:attrs="w.attrs">
<table py:attrs="w.attrs">
<tr py:for="i,c in enumerate(w.children_non_hidden)" class="${(i % 2 and 'even' or 'odd') + ((c.validator and getattr(c.validator, 'required', getattr(c.validator, 'not_empty', False))) and ' required' or '') + (c.error_msg and ' error' or '')}" title="${w.hover_help and c.help_text or None}" py:attrs="c.container_attrs" id="${c.compound_id}:container">
<th py:if="c.label"><label for="${c.id}">$c.label</label></th>
<td py:attrs="(not c.label) and dict(colspan='2') or None">
Expand Down
2 changes: 1 addition & 1 deletion tw2/forms/templates/textarea.kajiki
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<textarea xmlns:py="http://genshi.edgewall.org/" py:attrs="w.attrs">${w.value or ''}</textarea>
<textarea py:attrs="w.attrs">${w.value or ''}</textarea>
2 changes: 1 addition & 1 deletion tw2/forms/templates/vertical_selection_table.kajiki
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<table xmlns:py="http://genshi.edgewall.org/" py:attrs="w.attrs" >
<table py:attrs="w.attrs" >
<thead py:if="w.grouped_options[0][0]">
<tr>
<th py:for="group_name, options in w.grouped_options">${group_name}</th>
Expand Down

0 comments on commit 4738464

Please sign in to comment.