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

602: preserve order of columns when building secondary instance #672

Merged
merged 1 commit into from
Dec 1, 2023

Conversation

lindsay-stevens
Copy link
Contributor

Closes #602

Why is this the best possible solution? Were any other approaches considered?

Seems like main reason for sorting in the first place was to help satisfy string-based matching for XML output tests. Since there are XPath test facilities now, it's not necessary. These changes remove explicit sorting in survey.py and utils.py, and remove order randomisation in xls2json.py that happened via conversion of keys to set objects - it now uses dicts instead so that order is preserved.

There is still a bit of sorting going on in pyxform_test_case.py and xform_test_case.py but since that's purely for testing it would not affect #602.

What are the regression risks?

If XForm consumers (such as Collect or Enketo or other tools) expected the sorted behaviour, those consumers would have to sort elements instead of expecting the form elements to be pre-sorted. Similarly, pyxform library users would need to apply a sort if needed e.g. in the survey choices dict.

It's possible that some tests might randomly fail either in CI or later on, because of the string matching thing. In which case it would only be a failure related to element or attribute order. I ran the test suite about a dozen times to try and catch them all.

Does this change require updates to documentation? If so, please file an issue here and include the link below.

No I would say this is an internal implementation detail. The spec doesn't say the elements should be sorted.

Before submitting this PR, please make sure you have:

  • included test cases for core behavior and edge cases in tests
  • run nosetests and verified all tests pass
  • run black pyxform tests to format code
  • verified that any code or assets from external sources are properly credited in comments

- Seems like main reason for sorting in the first place was to help
  satisfy string-based matching for XML output tests. Since there are
  XPath test facilities now, it's not necessary.
- fix: remove explicit sorting in survey.py and utils.py
- fix: remove order randomisation in xls2json.py via conversion of
  keys to set objects - use dicts instead so that order is preserved.
- fix: tests broken by the above changes
- fix: add retry loop for shutting down server between test runs.
- add: test asserting column order for additional choices columns
@lognaturel lognaturel merged commit efd4768 into XLSForm:master Dec 1, 2023
10 checks passed
@lindsay-stevens lindsay-stevens deleted the pyxform-602 branch December 4, 2023 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Preserve order of columns when building secondary instance
2 participants