-
Notifications
You must be signed in to change notification settings - Fork 96
Item type and asset type validation in Data and Subscriptions #905
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
Merged
Merged
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
47c5002
Added validation for item types and thier options in an click epilog.
kevinlacaille b861774
Added validation for item types in get_asset() in the data client.
kevinlacaille 5deba79
Added validation for item types in request.
kevinlacaille 9358029
Added function to get supported assets and a validation function.
kevinlacaille 19f088b
Added validation for asset types.
kevinlacaille 688b23b
Added @translate_exceptions, but doesnt seem to work... hmmm
kevinlacaille 19d5ac1
Added validation in try/except, but not sure that is the best way. TBD
kevinlacaille d3e5fe5
Removed annoyinng index into asset_types and now can validate all ass…
kevinlacaille a1819c9
Addeds tests for validate_asset_type.
kevinlacaille bd43ec2
Added tests for get_supported_assets.
kevinlacaille 383deba
Bug fix: Flipped the order of item_type and name.
kevinlacaille 6c7faa1
Bug fix: item_types doesnt need a list
kevinlacaille 44a82b4
Removed list around item_types because item_types are now a click.Cho…
kevinlacaille 4328639
Added translation of Spcification exception.
kevinlacaille adb4bba
Unsupported asset type.
kevinlacaille 7df6274
Undoing bug fix. Will fix in a future ticket, #908.
kevinlacaille 7e8fdaa
Changed item types back to a comma separated string.
kevinlacaille 7e98d59
Validate asset types for each item type.
kevinlacaille 51c4485
Added test for multiple item types and asset types.
kevinlacaille 6a8eb49
Merge branch 'main' into item-type-case-insensitive-orders-subs-903
kevinlacaille bb70f60
Merge branch 'main' into item-type-case-insensitive-orders-subs-903
kevinlacaille bf0d3f5
Readded list to item_types.
kevinlacaille 4ccb908
Unparamaterized test_request_catalog_success.
kevinlacaille baae55a
Added docstring and postfix to test_validate_asset_type.
kevinlacaille 608fc51
Added callback function for item type.
kevinlacaille abbd994
Added docstring to validate_asset_type.
kevinlacaille b39f611
Reformatted data tests and duplicated data tests for subscriptions te…
kevinlacaille 3512f80
Reformatted asset_type validation. Now accepts multiple asset types f…
kevinlacaille bd6b7df
ClientError raised if more than 1 item type is provided.
kevinlacaille f1af245
linting
kevinlacaille 0ad9816
linting
kevinlacaille a3900d2
Renamed filename to better represent whats being tested.
kevinlacaille 5e41ec0
Replace awkward text wrapping with nice continuous text.
kevinlacaille 2d62bd2
Removed item type parametrization.
kevinlacaille c0cb296
Only test against one supported asset type.
kevinlacaille 03d3308
Renamed filename to better represent whats being tested.
kevinlacaille 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
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,89 @@ | ||
# Copyright 2022 Planet Labs PBC. | ||
# | ||
# 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 logging | ||
import pytest | ||
import click | ||
from planet.cli import data | ||
from planet.cli import subscriptions | ||
|
||
LOGGER = logging.getLogger(__name__) | ||
|
||
|
||
class MockContext: | ||
|
||
def __init__(self): | ||
self.obj = {} | ||
|
||
|
||
def test_item_types_success_data(): | ||
ctx = MockContext() | ||
result = data.check_item_types(ctx, 'item_types', ["PSScene"]) | ||
assert result == ["PSScene"] | ||
|
||
|
||
def test_item_types_fail_data(): | ||
ctx = MockContext() | ||
with pytest.raises(click.BadParameter): | ||
data.check_item_types(ctx, 'item_types', "bad_item_type") | ||
|
||
|
||
def test_item_type_success_data(): | ||
ctx = MockContext() | ||
item_type = "PSScene" | ||
result = data.check_item_type(ctx, 'item_type', item_type) | ||
assert result == item_type | ||
|
||
|
||
def test_item_type_fail_data(): | ||
ctx = MockContext() | ||
with pytest.raises(click.BadParameter): | ||
data.check_item_type(ctx, 'item_type', "bad_item_type") | ||
|
||
|
||
def test_item_type_too_many_item_types_data(): | ||
ctx = MockContext() | ||
with pytest.raises(click.BadParameter): | ||
data.check_item_types(ctx, 'item_type', "PSScene,SkySatScene") | ||
|
||
|
||
# Identical tests to above, but for subscriptions CLI | ||
def test_item_types_success_subscriptions(): | ||
ctx = MockContext() | ||
result = subscriptions.check_item_types(ctx, 'item_types', ["PSScene"]) | ||
assert result == ["PSScene"] | ||
|
||
|
||
def test_item_types_fail_subscriptions(): | ||
ctx = MockContext() | ||
with pytest.raises(click.BadParameter): | ||
subscriptions.check_item_types(ctx, 'item_types', "bad_item_type") | ||
|
||
|
||
def test_item_type_success_subscriptions(): | ||
ctx = MockContext() | ||
item_type = "PSScene" | ||
result = subscriptions.check_item_type(ctx, 'item_type', item_type) | ||
assert result == item_type | ||
|
||
|
||
def test_item_type_fail_subscriptions(): | ||
ctx = MockContext() | ||
with pytest.raises(click.BadParameter): | ||
subscriptions.check_item_type(ctx, 'item_type', "bad_item_type") | ||
|
||
|
||
def test_item_type_too_many_item_types_subscriptions(): | ||
ctx = MockContext() | ||
with pytest.raises(click.BadParameter): | ||
subscriptions.check_item_types(ctx, 'item_type', "PSScene,SkySatScene") |
This file was deleted.
Oops, something went wrong.
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
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.