Skip to content

Commit

Permalink
Fix incorrect subparser, missing exception guards
Browse files Browse the repository at this point in the history
  • Loading branch information
why-not-try-calmer committed Dec 21, 2023
1 parent bbbb5f1 commit c2b5b75
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
10 changes: 5 additions & 5 deletions qgispluginci/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ def cli():
action="append",
help="An additional asset path to add. Can be specified multiple times.",
)
package_parser.add_argument(
"--no-validation",
action="store_true",
help="Turn off validation of `release version`",
)

# changelog
changelog_parser = subparsers.add_parser(
Expand All @@ -88,11 +93,6 @@ def cli():
release_parser.add_argument(
"release_version", help="The version to be released (x.y.z)."
)
release_parser.add_argument(
"--no-validation",
action="store_true",
help="Turn off validation of `release version`",
)
release_parser.add_argument(
"--release-tag",
help="The release tag, if different from the version (e.g. vx.y.z).",
Expand Down
6 changes: 5 additions & 1 deletion qgispluginci/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,11 @@ def explore_config() -> Dict[str, Any]:
if path_to_file.is_file():
try:
return load_config(path_to_file, path_to_file.name)
except ConfigurationNotFound:
except (
ConfigurationNotFound,
configparser.NoSectionError,
KeyError,
):
pass
raise configuration_not_found

Expand Down
16 changes: 12 additions & 4 deletions test/test_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,16 +233,24 @@ def test_release_version_valid_invalid(self):

def test_release_version_validation_on(self):
parser = argparse.ArgumentParser()
parser.add_argument("release_version")
parser.add_argument("--no-validation", action="store_true")
subparsers = parser.add_subparsers(
title="commands", description="qgis-plugin-ci command", dest="command"
)
sub_parser = subparsers.add_parser("package")
sub_parser.add_argument("release_version")
sub_parser.add_argument("--no-validation", action="store_true")
args = parser.parse_args(["v1"])
with self.assertRaises(ValueError):
Parameters.validate_args(args)

def test_release_version_validation_off(self):
parser = argparse.ArgumentParser()
parser.add_argument("release_version")
parser.add_argument("--no-validation", action="store_true")
subparsers = parser.add_subparsers(
title="commands", description="qgis-plugin-ci command", dest="command"
)
sub_parser = subparsers.add_parser("package")
sub_parser.add_argument("release_version")
sub_parser.add_argument("--no-validation", action="store_true")
args = parser.parse_args([".", "--no-validation"])
Parameters.validate_args(args)

Expand Down

0 comments on commit c2b5b75

Please sign in to comment.