[Cleanup] SettingsDefinition minor improvements, better test maintainability
#861
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR covers a few minor areas:
Fixes for the SettingsQR Generator
SettingsConstants.get_detected_languages()scans the translation dir to see which languages are on board. But itsgetcwd()approach doesn't work in the SettingsQR Generator because the generator runs from a different shell context. Changing its directory reference to__file__guarantees that we can find our way to the translations subdir no matter which dir the instigating shell command is run from.Remove
if __name__ == "__main__":The SettingsQR Generator was using this python convention to run the
settings_definition.pyfile directly to extract theSettingsDefinition. But elsewhere we have preferred to avoid providing direct execution of individual source files. The SettingsQR Generator has been refactored so that this direct execution is no longer necessary.see: (pending PR)
Improve test maintainability
In #844 I struggled to update the SettingsQR tests correctly because they use pasted-in config strings:
seedsigner/tests/test_settings.py
Line 32 in 28124c6
This PR refactors the tests to provide a default config string that is generated directly from the current
SettingsDefinition, basically eliminating future maintenance issues. This is facilitated by a minor refactor inSettingsDefinition.get_defaults().Also guarantees that
SettingsEntry.abbreviated_namewill always have a value (is now set toattr_nameif none is provided). This was for convenience to avoid repeating this over and over again in the SettingsQR tests:Includes other minor maintainability edits.
Also anticipates the
Settingschange in #844 and changes the test that had been referencing the soon-to-be-removed "Coordinators" setting.Testing
Really just need to code review the changes to the tests and verify that they still pass. And then verify that we can still detect which languages are onboard when running the code.
The effect on the SettingsQR Generator is a separate matter that can be tested in its PR after this change is merged.
This pull request is categorized as a:
Checklist
pytestand made sure all unit tests pass before submitting the PRIf you modified or added functionality/workflow, did you add new unit tests?
I have tested this PR on the following platforms/os: