-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #383 from palewire/basemaps
- Loading branch information
Showing
2 changed files
with
135 additions
and
0 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,50 @@ | ||
"""Test basemaps related API enpoints.""" | ||
import pytest | ||
|
||
from datawrapper import Datawrapper | ||
|
||
|
||
def test_get_basemaps(): | ||
"""Test the get_basemaps method.""" | ||
dw = Datawrapper() | ||
basemaps_list = dw.get_basemaps() | ||
assert len(basemaps_list) > 0 | ||
|
||
|
||
def test_get_basemap(): | ||
"""Test the get_basemap method.""" | ||
dw = Datawrapper() | ||
|
||
# Test the standard query | ||
basemap_info = dw.get_basemap("iowa-counties") | ||
assert isinstance(basemap_info, dict) | ||
assert basemap_info['meta']['slug'] == 'usa-iowa-counties' | ||
assert basemap_info['meta']['projection'] == { | ||
'rotate': [93.49589653689938, -42.075128883839746], | ||
'type': 'geoAzimuthalEqualArea' | ||
} | ||
|
||
# Test the projection kwarg | ||
basemap_info = dw.get_basemap("iowa-counties", wgs84=True) | ||
assert basemap_info['meta']['projection'] == { | ||
'type': 'geoAzimuthalEqualArea' | ||
} | ||
|
||
# Test a missing slug | ||
with pytest.raises(Exception): | ||
dw.get_basemap("iowa-counties-zzz") | ||
|
||
|
||
def test_get_basemap_key(): | ||
"""Test the get_basemap_key method.""" | ||
dw = Datawrapper() | ||
|
||
# Test the standard query | ||
basemap_key = dw.get_basemap_key("iowa-counties", 'GEOID') | ||
assert isinstance(basemap_key, dict) | ||
assert basemap_key['label'] == 'FIPS' | ||
assert len(basemap_key['values']) == 99 | ||
|
||
# Test a missing slug | ||
with pytest.raises(Exception): | ||
dw.get_basemap_key("iowa-counties-zzz", 'GEOID') |