Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require labels for items in choice lists #534

Open
lognaturel opened this issue Apr 22, 2021 · 1 comment
Open

Require labels for items in choice lists #534

lognaturel opened this issue Apr 22, 2021 · 1 comment
Milestone

Comments

@lognaturel
Copy link
Contributor

lognaturel commented Apr 22, 2021

Currently, pyxform does not require labels for items in choice lists.

For dynamic selects, I can see an argument for them not being required because users could be building a list they only want to query and won't use in a select. However, I think that's pretty rare and for those advanced users, it's not a big deal to just add a label. In v1.4, if a user did build a dynamic select with a choice missing a label and used it in a select, there'd be a Validate error. In v1.5, there's a crash (narrowly addressed by #535).

For static selects, I don't see any use for a choice without a label. Currently there's no validation on this at all.

CC @MartijnR @pbowen-oc

    def test_choices_without_labels__for_static_selects__allowed(self):
        """
        Test choices without labels for static selects. Validate will NOT fail.
        """
        self.assertPyxformXform(
            md = """
            | survey   |                    |      |       |
            |          | type               | name | label |
            |          | select_one choices | a    | A     |
            | choices  |                    |      |       |
            |          | list_name          | name | label |
            |          | choices            | 1    |       |
            |          | choices            | 2    |       |
            """,
            xml__contains=[
                '<value>1</value>'
            ],
        )

    def test_choices_without_labels__for_dynamic_selects__allowed_by_pyxform(self):
        """
        Test choices without labels for dynamic selects. Validate will fail.
        """
        self.assertPyxformXform(
            md = """
            | survey   |                    |      |       |               |
            |          | type               | name | label | choice_filter |
            |          | select_one choices | a    | A     | true()        |
            | choices  |                    |      |       |
            |          | list_name          | name | label |
            |          | choices            | 1    |       |
            |          | choices            | 2    |       |
            """,
            run_odk_validate=False,
            xml__contains=[
                '<instance id="choices">',
                '<item>',
                '<name>1</name>'
            ],
        )
@lognaturel
Copy link
Contributor Author

@lindsay-stevens could you please briefly look into how this intersects with #679? Should we close this?

@lognaturel lognaturel added this to the Next milestone Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant