-
Notifications
You must be signed in to change notification settings - Fork 441
Fix geocoder returning empty when a longer prefix lacks the requested language #323
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
Open
gaoflow
wants to merge
1
commit into
daviddrysdale:dev
Choose a base branch
from
gaoflow:fix-geocoder-prefix-language-fallback
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+25
−2
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -178,6 +178,30 @@ def testGetDescriptionForNonGeographicalNumberWithGeocodingPrefix(self): | |
| # We have a geocoding prefix, but we shouldn't use it since this is not geographical. | ||
| self.assertEqual("South Korea", description_for_number(KO_MOBILE, _ENGLISH)) | ||
|
|
||
| def testPrefixFallsBackToShorterPrefixWhenLanguageMissing(self): | ||
| # When a longer prefix exists in the geocoding data but lacks the requested | ||
| # language, the lookup must continue to shorter prefixes rather than returning | ||
| # empty immediately. This can occur when only a subset of sub-prefixes carry | ||
| # alternative-language entries for a region. | ||
| # | ||
| # Simulate: '1212' has 'en', '12123' exists only for 'de'. | ||
| # Asking for 'fr' on a number whose digits start with 12123 should fall back | ||
| # to '1212' and return the English name (since French falls back to English), | ||
| # not the empty string from '12123'. | ||
| TEST_GEOCODE_DATA['12123'] = {'de': u("TestDistrict")} | ||
| try: | ||
| # US_NUMBER3 is +1 212-812-0000; its prefix digits start with '12128' so | ||
| # it won't hit '12123'. Use a fabricated number whose digits begin '12123'. | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: the first sentence of the comment is unhelpful, please remove it. |
||
| test_num = FrozenPhoneNumber(country_code=1, national_number=2123000000) | ||
| # '12123' has no 'fr', '1212' has 'en' -> French should fall back to 'NY' | ||
| self.assertEqual("NY", _prefix_description_for_number( | ||
| TEST_GEOCODE_DATA, TEST_GEOCODE_LONGEST_PREFIX, test_num, "fr")) | ||
| # 'de' is directly present in '12123', so German gets the detailed name | ||
| self.assertEqual("TestDistrict", _prefix_description_for_number( | ||
| TEST_GEOCODE_DATA, TEST_GEOCODE_LONGEST_PREFIX, test_num, "de")) | ||
| finally: | ||
| del TEST_GEOCODE_DATA['12123'] | ||
|
|
||
| def testCoverage(self): | ||
| # Python version extra tests | ||
| invalid_number = PhoneNumber(country_code=210, national_number=123456) | ||
|
|
||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please could you add "Python version extra test" at the top of the comment as reminder that this has no equivalent Java test.