Skip to content

Commit

Permalink
Fix incorrect subparser, missing exception guards (release 2.8.2) (#262)
Browse files Browse the repository at this point in the history
* Fix incorrect subparser, missing exception guards

* argument name
  • Loading branch information
why-not-try-calmer authored Dec 21, 2023
1 parent bbbb5f1 commit df39548
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 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
20 changes: 14 additions & 6 deletions test/test_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,17 +233,25 @@ 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")
args = parser.parse_args(["v1"])
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(["package", "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")
args = parser.parse_args([".", "--no-validation"])
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(["package", "v1", "--no-validation"])
Parameters.validate_args(args)


Expand Down

0 comments on commit df39548

Please sign in to comment.