Skip to content
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

Improve test coverage: CLI #614

Merged
merged 5 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 6 additions & 21 deletions pystac_client/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def set_warnings(error: Optional[List[str]], ignore: Optional[List[str]]) -> Non
if ignore is not None and len(ignore) == 0:
warnings.filterwarnings("ignore", category=PystacClientWarning)
if error is not None and len(error) == 0:
warnings.filterwarnings("ignore", category=PystacClientWarning)
gadomski marked this conversation as resolved.
Show resolved Hide resolved
warnings.filterwarnings("error", category=PystacClientWarning)

# Then set filters on any specific classes
category_options = {
Expand Down Expand Up @@ -254,12 +254,6 @@ def parse_args(args: List[str]) -> Dict[str, Any]:
nargs="*",
help=f"Query properties of form KEY=VALUE ({','.join(OPS)} supported)",
)
search_group.add_argument(
"-q",
nargs="*",
help="DEPRECATED. Use --query instead. Query properties of form "
"KEY=VALUE (<, >, <=, >=, = supported)",
)
gadomski marked this conversation as resolved.
Show resolved Hide resolved
search_group.add_argument(
"--filter",
help="Filter on queryables using language specified in filter-lang parameter",
Expand Down Expand Up @@ -306,6 +300,10 @@ def parse_args(args: List[str]) -> Dict[str, Any]:
if data["type"] == "Feature":
parsed_args["intersects"] = data["geometry"]
elif data["type"] == "FeatureCollection":
logger.warning(
gadomski marked this conversation as resolved.
Show resolved Hide resolved
"When the input to intersects is a FeatureCollection, "
"only the first feature geometry is used."
)
parsed_args["intersects"] = data["features"][0]["geometry"]
else:
parsed_args["intersects"] = data
Expand All @@ -326,14 +324,6 @@ def parse_args(args: List[str]) -> Dict[str, Any]:
if "json" in parsed_args["filter_lang"]:
parsed_args["filter"] = json.loads(parsed_args["filter"])

if "q" in parsed_args:
logger.warning("Argument -q is deprecated, use --query instead")
if "query" not in parsed_args:
parsed_args["query"] = parsed_args["q"]
else:
logger.error("Both -q and --query arguments specified, ignoring -q")
del parsed_args["q"]

return parsed_args


Expand Down Expand Up @@ -368,12 +358,7 @@ def cli() -> int:
return search(client, **args)
elif cmd == "collections":
return collections(client, **args)
else:
gadomski marked this conversation as resolved.
Show resolved Hide resolved
logger.error(
f"Command '{cmd}' is not a valid command. "
"must be 'search' or 'collections'",
)
return 1
return 1
except Exception as e:
logger.error(e, exc_info=True)
return 1
Expand Down

This file was deleted.

Loading
Loading