Skip to content

Commit

Permalink
Make check for reserved entity properties case-insensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
lognaturel committed Sep 15, 2023
1 parent c67c0aa commit 56f9906
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyxform/entities/entities_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def validate_entity_saveto(

error_start = f"{constants.ROW_FORMAT_STRING % row_number} Invalid save_to name:"

if save_to == "name" or save_to == "label":
if save_to.lower() == "name" or save_to.lower() == "label":
raise PyXFormError(
f"{error_start} the entity property name '{save_to}' is reserved."
)
Expand Down
34 changes: 34 additions & 0 deletions tests/test_entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,23 @@ def test_name_in_saveto_column__errors(self):
],
)

def test_naMe_in_saveto_column__errors(self):
self.assertPyxformXform(
name="data",
md="""
| survey | | | | |
| | type | name | label | save_to |
| | text | a | A | naMe |
| entities | | | | |
| | dataset | label | | |
| | trees | a | | |
""",
errored=True,
error__contains=[
"[row : 2] Invalid save_to name: the entity property name 'naMe' is reserved."
],
)

def test_label_in_saveto_column__errors(self):
self.assertPyxformXform(
name="data",
Expand All @@ -249,6 +266,23 @@ def test_label_in_saveto_column__errors(self):
],
)

def test_lAbEl_in_saveto_column__errors(self):
self.assertPyxformXform(
name="data",
md="""
| survey | | | | |
| | type | name | label | save_to |
| | text | a | A | lAbEl |
| entities | | | | |
| | dataset | label | | |
| | trees | a | | |
""",
errored=True,
error__contains=[
"[row : 2] Invalid save_to name: the entity property name 'lAbEl' is reserved."
],
)

def test_system_prefix_in_saveto_column__errors(self):
self.assertPyxformXform(
name="data",
Expand Down

0 comments on commit 56f9906

Please sign in to comment.