From 56f9906a2352c0ecea6e3011da574b47afbbf258 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9l=C3=A8ne=20Martin?= Date: Fri, 15 Sep 2023 12:36:38 -0700 Subject: [PATCH] Make check for reserved entity properties case-insensitive --- pyxform/entities/entities_parsing.py | 2 +- tests/test_entities.py | 34 ++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/pyxform/entities/entities_parsing.py b/pyxform/entities/entities_parsing.py index 09cb8149..7a629d17 100644 --- a/pyxform/entities/entities_parsing.py +++ b/pyxform/entities/entities_parsing.py @@ -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." ) diff --git a/tests/test_entities.py b/tests/test_entities.py index 794a327e..6127f616 100644 --- a/tests/test_entities.py +++ b/tests/test_entities.py @@ -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", @@ -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",