Repository navigation
Check the codes in station corrections against ISO - #1624
Merged
Merged
Conversation
The schema only checks the shape of country, region and language codes. Some proposals upstream use codes that look right but do not exist, like HU-BP for Budapest, which is HU-BU. Check the shipped corrections against pycountry: the country folder, the region (within its country), and every language code.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Breaking change
None. Tests only.
Proposed change
The schema in
radios.correctionschecks the shape of codes, like^[A-Z]{2}-[A-Z0-9]{1,3}$for a region. That lets codes through that look right but do not exist. While porting the radio-database proposals, 21 Hungarian ones usedHU-BPfor Budapest, which isHU-BU, and one Greek one usedGR-1, an old code that was removed. I caught those by hand (#1606); this makes the test suite catch them.A new test checks every shipped correction file against pycountry, which is already a dependency:
countrycodeof the same correction when it sets one.The check lives in the tests, not in the schema: an
In(...)with every region code would put thousands of codes intoschema.json. A second test feeds the helper a few wrong codes, so it is known to catch them.All 145 correction files on main pass. What it cannot check: whether a region matches the country of the station itself when the correction does not set
countrycode, since that country lives in the live API and the tests stay offline.Type of change
Additional information
Checklist
poetry run pytestpasses locally. A pull request cannot be merged unless CI is green.poetry run prek run --all-filespasses (lint, format, and type checks).