Skip to content

Commit

Permalink
Do not warn on unlabeled field-lists
Browse files Browse the repository at this point in the history
  • Loading branch information
yanokwa committed Jul 28, 2021
1 parent 2e631b1 commit b0ccab6
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pyxform/aliases.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,6 @@
"end",
"today",
]
begin_group = ["begin group", "begin_group"]
begin_repeat = ["begin repeat", "begin_repeat"]
osm = {"osm": constants.OSM_TYPE}
1 change: 1 addition & 0 deletions pyxform/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
LIST_NAME = "list name"
CASCADING_SELECT = "cascading_select"
TABLE_LIST = "table-list" # hyphenated because it goes in appearance, and convention for appearance column is dashes # noqa
FIELD_LIST = "field-list"

# The following are the possible sheet names:
SURVEY = "survey"
Expand Down
Binary file added pyxform/tests/example_xls/warnings.xls
Binary file not shown.
93 changes: 93 additions & 0 deletions pyxform/tests_v1/test_fieldlist_labels.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# -*- coding: utf-8 -*-
"""
Test field-list labels
"""
from pyxform.tests_v1.pyxform_test_case import PyxformTestCase


class FieldListLabels(PyxformTestCase):
"""Test unlabeled group"""

def test_unlabeled_group(self):
warnings = []

survey = self.md_to_pyxform_survey(
"""
| survey | | | |
| | type | name | label |
| | begin_group | my-group | |
| | text | my-text | my-text |
| | end_group | | |
""",
warnings=warnings,
)

self.assertTrue(len(warnings) == 1)
self.assertTrue("[row : 2] Group has no label" in warnings[0])

def test_unlabeled_group_alternate_syntax(self):
warnings = []

survey = self.md_to_pyxform_survey(
"""
| survey | | | |
| | type | name | label::English (en) |
| | begin group | my-group | |
| | text | my-text | my-text |
| | end group | | |
""",
warnings=warnings,
)

self.assertTrue(len(warnings) == 1)
self.assertTrue("[row : 2] Group has no label" in warnings[0])

def test_unlabeled_group_fieldlist(self):
warnings = []

survey = self.md_to_pyxform_survey(
"""
| survey | | | | |
| | type | name | label | appearance |
| | begin_group | my-group | | field-list |
| | text | my-text | my-text | |
| | end_group | | | |
""",
warnings=warnings,
)

self.assertTrue(len(warnings) == 0)

def test_unlabeled_repeat(self):
warnings = []

survey = self.md_to_pyxform_survey(
"""
| survey | | | |
| | type | name | label |
| | begin_repeat | my-repeat | |
| | text | my-text | my-text |
| | end_repeat | | |
""",
warnings=warnings,
)

self.assertTrue(len(warnings) == 1)
self.assertTrue("[row : 2] Repeat has no label" in warnings[0])

def test_unlabeled_repeat_fieldlist(self):
warnings = []

survey = self.md_to_pyxform_survey(
"""
| survey | | | | |
| | type | name | label | appearance |
| | begin_repeat | my-repeat | | field-list |
| | text | my-text | my-text | |
| | end_repeat | | | |
""",
warnings=warnings,
)

self.assertTrue(len(warnings) == 1)
self.assertTrue("[row : 2] Repeat has no label" in warnings[0])

0 comments on commit b0ccab6

Please sign in to comment.