Skip to content

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
grzesiek2010 committed Nov 21, 2023
1 parent 2b80707 commit 47c3e8d
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions tests/test_rows.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# -*- coding: utf-8 -*-
"""
Test text rows parameter.
"""
from tests.pyxform_test_case import PyxformTestCase


class TestRows(PyxformTestCase):
def test_adding_rows_to_the_body_if_set_in_its_own_column(
self,
):
self.assertPyxformXform(
name="data",
md="""
| survey | | | | |
| | type | name | label | body::rows |
| | text | name | Name | 7 |
""",
xml__xpath_match=["/h:html/h:body/x:input[@ref='/data/name' and @rows='7']"],
)

def test_adding_rows_to_the_body_if_set_in_parameters(
self,
):
self.assertPyxformXform(
name="data",
md="""
| survey | | | | |
| | type | name | label | parameters |
| | text | name | Name | rows=7 |
""",
xml__xpath_match=["/h:html/h:body/x:input[@ref='/data/name' and @rows='7']"],
)

def test_throwing_error_if_rows_set_in_parameters_but_the_value_is_not_an_integer(
self,
):
parameters = ("rows=", "rows=foo", "rows=7.5")
md = """
| survey | | | | |
| | type | name | label | parameters |
| | text | name | Name | {case} |
"""
for case in parameters:
with self.subTest(msg=case):
self.assertPyxformXform(
name="data",
md=md.format(case=case),
errored=True,
error__contains=["Parameter rows must have an integer value."],
)

0 comments on commit 47c3e8d

Please sign in to comment.