-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
more robust fetch values from result data structure (#58)
- Loading branch information
Showing
2 changed files
with
37 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from opencage.batch import OpenCageBatchGeocoder | ||
|
||
batch = OpenCageBatchGeocoder({}) | ||
|
||
def test_deep_get_result_value(): | ||
result = { | ||
'annotations': { | ||
'FIPS': { | ||
'state': 'CA' | ||
} | ||
}, | ||
'components': { | ||
'street': 'Main Road' | ||
} | ||
} | ||
|
||
assert batch.deep_get_result_value(result, ['hello', 'world']) == None | ||
|
||
assert batch.deep_get_result_value(result, ['components', 'street']) == 'Main Road' | ||
assert batch.deep_get_result_value(result, ['components', 'city']) == None | ||
assert batch.deep_get_result_value(result, ['components', 'city'], '') == '' | ||
|
||
assert batch.deep_get_result_value([], ['hello', 'world']) == None | ||
assert batch.deep_get_result_value(None, ['hello', 'world']) == None |