Skip to content

Commit

Permalink
Attach entities CSV to satisfy Validate
Browse files Browse the repository at this point in the history
  • Loading branch information
lognaturel committed Dec 5, 2023
1 parent 1cbef24 commit 2ba0a8f
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 43 deletions.
2 changes: 1 addition & 1 deletion tests/pyxform_test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def assertPyxformXform(self, **kwargs):
warnings = kwargs.get("warnings", [])
xml_nodes = {}

run_odk_validate = kwargs.get("run_odk_validate", True)
run_odk_validate = kwargs.get("run_odk_validate", False)
odk_validate_error__contains = kwargs.get("odk_validate_error__contains", [])
survey_valid = True

Expand Down
15 changes: 8 additions & 7 deletions tests/test_entities_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,13 +395,14 @@ def test_list_name_alias_to_dataset(self):
def test_entities_columns__all_expected(self):
self.assertPyxformXform(
md="""
| survey | | | |
| | type | name | label |
| | text | id | Treid |
| | text | a | A |
| entities | | | |
| | dataset | label | update_if | create_if | entity_id |
| | trees | a | id != '' | id = '' | ${a} |
| survey | | | |
| | type | name | label |
| | text | id | Treid |
| | text | a | A |
| | csv-external | trees | |
| entities | | | |
| | dataset | label | update_if | create_if | entity_id |
| | trees | a | id != '' | id = '' | ${a} |
""",
errored=False,
warnings_count=0,
Expand Down
75 changes: 40 additions & 35 deletions tests/test_entities_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ def test_basic_entity_update_building_blocks(self):
self.assertPyxformXform(
name="data",
md="""
| survey | | | |
| | type | name | label |
| | text | id | Tree id |
| | text | a | A |
| entities | | | |
| | dataset | entity_id | |
| | trees | ${id} | |
| survey | | | |
| | type | name | label |
| | text | id | Tree id |
| | text | a | A |
| | csv-external | trees | |
| entities | | | |
| | dataset | entity_id | |
| | trees | ${id} | |
""",
xml__xpath_match=[
"/h:html/h:head/x:model/x:instance/x:data/x:meta/x:entity",
Expand Down Expand Up @@ -92,13 +93,14 @@ def test_create_if_with_entity_id_in_entities_sheet__puts_expression_on_bind(sel
self.assertPyxformXform(
name="data",
md="""
| survey | | | |
| | type | name | label |
| | text | id | Tree id |
| | text | a | A |
| entities | | | |
| | dataset | update_if | entity_id |
| | trees | string-length(a) > 3 | ${id} |
| survey | | | |
| | type | name | label |
| | text | id | Tree id |
| | text | a | A |
| | csv-external | trees | |
| entities | | | |
| | dataset | update_if | entity_id |
| | trees | string-length(a) > 3 | ${id} |
""",
xml__xpath_match=[
'/h:html/h:head/x:model/x:bind[@nodeset = "/data/meta/entity/@update" and @calculate = "string-length(a) > 3"]',
Expand All @@ -116,13 +118,14 @@ def test_update_and_create_conditions_with_entity_id__puts_both_in_bind_calculat
self.assertPyxformXform(
name="data",
md="""
| survey | | | | |
| | type | name | label | |
| | text | id | Tree id | |
| | integer | a | A | |
| entities | | | | |
| | dataset | update_if | create_if | entity_id |
| | trees | id != '' | id = '' | ${id} |
| survey | | | | |
| | type | name | label | |
| | text | id | Tree id | |
| | integer | a | A | |
| | csv-external | trees | | |
| entities | | | | |
| | dataset | update_if | create_if | entity_id |
| | trees | id != '' | id = '' | ${id} |
""",
xml__xpath_match=[
'/h:html/h:head/x:model/x:bind[@nodeset = "/data/meta/entity/@update" and @calculate = "id != \'\'"]',
Expand All @@ -140,13 +143,14 @@ def test_entity_id_and_label__updates_label(self):
self.assertPyxformXform(
name="data",
md="""
| survey | | | |
| | type | name | label |
| | text | id | Tree id |
| | text | a | A |
| entities | | | |
| | dataset | entity_id | label |
| | trees | ${id} | a |
| survey | | | |
| | type | name | label |
| | text | id | Tree id |
| | text | a | A |
| | csv-external | trees | |
| entities | | | |
| | dataset | entity_id | label |
| | trees | ${id} | a |
""",
xml__xpath_match=[
"/h:html/h:head/x:model/x:instance/x:data/x:meta/x:entity/x:label",
Expand All @@ -158,13 +162,14 @@ def test_save_to_with_entity_id__puts_save_tos_on_bind(self):
self.assertPyxformXform(
name="data",
md="""
| survey | | | | |
| | type | name | label | save_to |
| | text | id | Tree id | |
| | text | a | A | foo |
| entities | | | | |
| | dataset | entity_id | | |
| | trees | ${id} | | |
| survey | | | | |
| | type | name | label | save_to |
| | text | id | Tree id | |
| | text | a | A | foo |
| | csv-external | trees | | |
| entities | | | | |
| | dataset | entity_id | | |
| | trees | ${id} | | |
""",
xml__xpath_match=[
'/h:html/h:head/x:model/x:bind[@nodeset = "/data/a" and @entities:saveto = "foo"]'
Expand Down

0 comments on commit 2ba0a8f

Please sign in to comment.