-
Notifications
You must be signed in to change notification settings - Fork 136
wms_service_cache should use complete url #3176
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
JanEisermann
wants to merge
15
commits into
Open-MSS:develop
Choose a base branch
from
JanEisermann:wms_service_cache_2841
base: develop
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.
Open
Changes from 4 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
6c782b3
key the wms service cache by a slug of the full url
JanEisermann c3c211a
build the capabilities base url with urllib instead of str.replace
JanEisermann 46dd4d0
key the wms service cache by the normalized url instead of a slug
JanEisermann 55e1bfc
add tests for the wms service cache key
JanEisermann 7d4f6b7
removed unnecessary constant
JanEisermann 6fe47bd
linux-aarch64 added (#3169)
ReimarBauer bb94ff1
overlay for vibepod with respecting the users .pixi dir (#3170)
ReimarBauer b048e8d
unexpected argument in dataaccess and test for reload (#3175)
JanEisermann 8ac5551
only default UPLOAD_FOLDER works with the chat (#3172)
JanEisermann 0bff314
Improve templates for bootstrap 5 (#3171)
JanEisermann a0e20f2
Bump prefix-dev/setup-pixi from 0.10.0 to 0.10.2 (#3173)
dependabot[bot] bdc9a87
Bump zgosalvez/github-actions-ensure-sha-pinned-actions (#3167)
dependabot[bot] afc9c7e
Bump coverallsapp/github-action from 2.3.7 to 2.3.8 (#3159)
dependabot[bot] 47dd876
Bump actions/checkout from 7.0.0 to 7.0.1 (#3157)
dependabot[bot] 7df3722
corrected copyright description
JanEisermann 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
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 |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| # -*- coding: utf-8 -*- | ||
| """ | ||
|
|
||
| tests._test_utils.test_service_manager | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| This module provides pytest functions to tests mslib.utils.service_manager | ||
|
|
||
| This file is part of MSS. | ||
|
|
||
| :copyright: Copyright 2025 Reimar Bauer | ||
| :copyright: Copyright 2025-2026 by the MSS team, see AUTHORS. | ||
| :license: APACHE-2.0, see LICENSE for details. | ||
|
Member
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. this looks like a new test module, ©️ Copyright 2026 Jan Eisermann and there are currently no other contributions? by the team, or? |
||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| """ | ||
| import pytest | ||
|
|
||
| from mslib.utils.service_manager import WMSServiceManager, service_cache_key, strip_request_params | ||
|
|
||
|
|
||
| class TestStripRequestParams: | ||
| @pytest.mark.parametrize("url,expected", [ | ||
| ("http://example.com/wms", "http://example.com/wms"), | ||
| ("http://example.com/wms?service=WMS&request=GetCapabilities", "http://example.com/wms"), | ||
| ("http://example.com/wms?SERVICE=WMS&REQUEST=GetCapabilities", "http://example.com/wms"), | ||
| ("http://example.com/wms?dataset=a&service=WMS", "http://example.com/wms?dataset=a"), | ||
| # other parameters keep their original order | ||
| ("http://example.com/wms?b=2&a=1", "http://example.com/wms?b=2&a=1"), | ||
| ]) | ||
| def test_strip_request_params(self, url, expected): | ||
| assert strip_request_params(url) == expected | ||
|
|
||
|
|
||
| class TestServiceCacheKey: | ||
| @pytest.mark.parametrize("url,other", [ | ||
| # a port is not the same as a path element | ||
| ("http://example.com:1/wms", "http://example.com/1/wms"), | ||
| ("https://example.com:8080/wms", "https://example.com/8080/wms"), | ||
| # nor is a host boundary the same as a path separator | ||
| ("http://example.com/wms", "http://example/com/wms"), | ||
| # different hosts, same words | ||
| ("http://a.example.com/wms", "http://a-example-com/wms"), | ||
| # parameters must not collapse into the path either | ||
| ("http://example.com/wms?dataset=a", "http://example.com/wms/dataset/a"), | ||
| ("http://example.com/wms?dataset=a&layer=b", "http://example.com/wms?dataset=a-layer-b"), | ||
| # a parameter value separator is not a parameter separator | ||
| ("http://example.com/wms?dataset=a&layer=b", "http://example.com/wms?dataset=a%26layer%3Db"), | ||
| ]) | ||
| def test_distinct_urls_get_distinct_keys(self, url, other): | ||
| assert service_cache_key(url) != service_cache_key(other) | ||
|
|
||
| @pytest.mark.parametrize("url,other", [ | ||
| # the GetCapabilities request itself is not part of the service | ||
| ("http://example.com/wms", | ||
| "http://example.com/wms?service=WMS&request=GetCapabilities"), | ||
| ("http://example.com/wms?dataset=a", | ||
| "http://example.com/wms?service=WMS&dataset=a&request=GetCapabilities"), | ||
| # parameter order does not matter | ||
| ("http://example.com/wms?dataset=a&layer=b", | ||
| "http://example.com/wms?layer=b&dataset=a"), | ||
| # scheme and host are case insensitive | ||
| ("http://example.com/wms", "HTTP://Example.COM/wms"), | ||
| ("http://example.com:1/wms", "HTTP://Example.COM:1/wms"), | ||
| ]) | ||
| def test_equivalent_urls_share_a_key(self, url, other): | ||
| assert service_cache_key(url) == service_cache_key(other) | ||
|
|
||
| @pytest.mark.parametrize("url,other", [ | ||
| # the path is case sensitive | ||
| ("http://example.com/wms", "http://example.com/WMS"), | ||
| # so are parameter names and values | ||
| ("http://example.com/wms?dataset=a", "http://example.com/wms?dataset=A"), | ||
| ("http://example.com/wms?dataset=a", "http://example.com/wms?DATASET=a"), | ||
| # a scheme is not just a name | ||
| ("http://example.com/wms", "https://example.com/wms"), | ||
| ]) | ||
| def test_case_and_scheme_are_kept(self, url, other): | ||
| assert service_cache_key(url) != service_cache_key(other) | ||
|
|
||
|
|
||
| class TestWMSServiceManager: | ||
| @pytest.fixture(autouse=True) | ||
| def _cache(self): | ||
| manager = WMSServiceManager() | ||
| manager.clear_cache() | ||
| yield | ||
| manager.clear_cache() | ||
|
|
||
| def test_cache_and_get_service(self): | ||
| manager = WMSServiceManager() | ||
| assert manager.get_service("http://example.com/wms") is None | ||
| manager.cache_service("http://example.com/wms", "wms") | ||
| assert manager.get_service("http://example.com/wms") == "wms" | ||
|
|
||
| def test_get_service_by_equivalent_url(self): | ||
| manager = WMSServiceManager() | ||
| manager.cache_service("http://example.com/wms?dataset=a", "wms") | ||
| assert manager.get_service( | ||
| "http://example.com/wms?request=GetCapabilities&dataset=a&service=WMS") == "wms" | ||
|
|
||
| @pytest.mark.parametrize("url,other", [ | ||
| ("http://example.com:1/wms", "http://example.com/1/wms"), | ||
| ("http://example.com/wms?dataset=a", "http://example.com/wms?dataset=b"), | ||
| ("http://example.com/wms?dataset=a", "http://example.com/wms"), | ||
| ]) | ||
| def test_distinct_services_do_not_share_an_entry(self, url, other): | ||
| manager = WMSServiceManager() | ||
| manager.cache_service(url, "wms") | ||
| assert manager.get_service(other) is None | ||
|
|
||
| def test_shared_cache_between_instances(self): | ||
| WMSServiceManager().cache_service("http://example.com/wms", "wms") | ||
| assert WMSServiceManager().get_service("http://example.com/wms") == "wms" | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.