-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Consolidate and fix item render params * Update changelog
- Loading branch information
1 parent
b22391d
commit 6f8e80b
Showing
5 changed files
with
94 additions
and
55 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
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,56 @@ | ||
import unittest | ||
from urllib.parse import quote_plus | ||
|
||
from ..render import DefaultRenderConfig | ||
|
||
multi_assets = DefaultRenderConfig( | ||
assets=["data1", "data2"], | ||
render_params={"colormap_name": "terrain", "rescale": [-1000, 4000]}, | ||
minzoom=8, | ||
) | ||
|
||
single_asset = DefaultRenderConfig( | ||
assets=["data1"], | ||
render_params={"colormap_name": "terrain", "rescale": [-1000, 4000]}, | ||
minzoom=8, | ||
) | ||
|
||
no_assets = DefaultRenderConfig( | ||
render_params={ | ||
"expression": ("asset1," "0.45*asset2," "asset3/asset1"), | ||
"colormap_name": "terrain", | ||
"rescale": [-1000, 4000], | ||
}, | ||
minzoom=8, | ||
) | ||
|
||
|
||
class TestRenderParams(unittest.TestCase): | ||
def test_multi_asset(self) -> None: | ||
qs = multi_assets.get_full_render_qs("my_collection_id", "my_item_id") | ||
self.assertEqual( | ||
qs, | ||
"collection=my_collection_id&item=my_item_id&assets=data1&assets=data2&colormap_name=terrain&rescale=-1000,4000", | ||
) | ||
|
||
def test_single_asset(self) -> None: | ||
qs = single_asset.get_full_render_qs("my_collection_id", "my_item_id") | ||
self.assertEqual( | ||
qs, | ||
"collection=my_collection_id&item=my_item_id&assets=data1&colormap_name=terrain&rescale=-1000,4000", | ||
) | ||
|
||
def test_no_asset(self) -> None: | ||
qs = no_assets.get_full_render_qs("my_collection_id", "my_item_id") | ||
encoded_params = quote_plus("asset1,0.45*asset2,asset3/asset1") | ||
self.assertEqual( | ||
qs, | ||
f"collection=my_collection_id&item=my_item_id&expression={encoded_params}&colormap_name=terrain&rescale=-1000,4000", | ||
) | ||
|
||
def test_collection_only(self) -> None: | ||
qs = single_asset.get_full_render_qs("my_collection_id") | ||
self.assertEqual( | ||
qs, | ||
"collection=my_collection_id&assets=data1&colormap_name=terrain&rescale=-1000,4000", | ||
) |
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