diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index c05a56a6..021b9e56 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -18,5 +18,12 @@ # - Because you must use a hash, you need to append to this list in a follow-up # commit to the actual reformatting commit that you are trying to ignore. +# Tox configuration and pylint fixes +b87508a41011b06637a9c67e51082c55befc0929 +a507c6449d9bbe3ae02506b27e45272b96635216 +1614a6ae75825afd49d996d5a44144ba36da47bd +d847780a4d179485bc76f57e56951ce380eae26a +8405f3b47c97927326b6eaae65b9bbe43f7d5952 + # Format all Python files with Black formatter b5cbd9480cef12fee05ae6cf68aaae5aaa931969 diff --git a/distributedcloud-client/dcmanagerclient/api/v1/sw_patch_manager.py b/distributedcloud-client/dcmanagerclient/api/v1/sw_patch_manager.py index 4dfa7e9c..ab25e624 100644 --- a/distributedcloud-client/dcmanagerclient/api/v1/sw_patch_manager.py +++ b/distributedcloud-client/dcmanagerclient/api/v1/sw_patch_manager.py @@ -22,4 +22,4 @@ SW_UPDATE_TYPE_PATCH = "patch" class SwPatchManager(SwUpdateManager): def __init__(self, http_client): super().__init__(http_client, update_type=SW_UPDATE_TYPE_PATCH) - self.extra_args = ["upload-only", "patch"] + self.extra_args = ["upload-only", "patch_id"] diff --git a/distributedcloud-client/dcmanagerclient/commands/v1/sw_patch_manager.py b/distributedcloud-client/dcmanagerclient/commands/v1/sw_patch_manager.py index 0fde5d1d..ebed1e7a 100644 --- a/distributedcloud-client/dcmanagerclient/commands/v1/sw_patch_manager.py +++ b/distributedcloud-client/dcmanagerclient/commands/v1/sw_patch_manager.py @@ -14,8 +14,6 @@ # limitations under the License. # -import os - from dcmanagerclient.commands.v1 import sw_update_manager @@ -62,9 +60,8 @@ class CreatePatchUpdateStrategy( ) parser.add_argument( - "--patch", - required=False, - help="Path to a patch to upload.", + "patch_id", + help="The patch ID to upload/apply on the subcloud.", ) return parser @@ -75,8 +72,8 @@ class CreatePatchUpdateStrategy( kwargs_dict["upload-only"] = "true" else: kwargs_dict["upload-only"] = "false" - if parsed_args.patch: - kwargs_dict["patch"] = os.path.abspath(parsed_args.patch) + + kwargs_dict["patch_id"] = parsed_args.patch_id class ShowPatchUpdateStrategy( diff --git a/distributedcloud-client/dcmanagerclient/tests/v1/test_patch_update_strategy.py b/distributedcloud-client/dcmanagerclient/tests/v1/test_patch_update_strategy.py index 405828c1..a93c2f7c 100644 --- a/distributedcloud-client/dcmanagerclient/tests/v1/test_patch_update_strategy.py +++ b/distributedcloud-client/dcmanagerclient/tests/v1/test_patch_update_strategy.py @@ -29,12 +29,34 @@ class TestPatchUpdateStrategy(UpdateStrategyMixin, base.BaseCommandTest): self.manager_to_test = self.sw_update_manager self.expected_strategy_type = self.manager_to_test.update_type + def test_create_strategy(self): + """Test that a strategy needs a patch_id option""" + + # mock the result of the API call + strategy = utils.make_strategy( + strategy_type=self.expected_strategy_type, + extra_args={"patch_id": "stx-10.1"}, + ) + + self.manager_to_test.create_sw_update_strategy.return_value = strategy + + # invoke the backend method for the CLI. + # Assert raises Exception for API call without required parameter + self.assertRaises(SystemExit, self.call, self.create_command, []) + + # Assert call will not raise Exception for API call with required parameter + try: + self.call(self.create_command, ["stx-10.1"]) + except Exception: + self.fail("Unexpected Exception raised") + def test_create_strategy_upload_only(self): """Test that a strategy can be created with the --upload-only option""" # mock the result of the API call strategy = utils.make_strategy( - strategy_type=self.expected_strategy_type, extra_args={"upload-only": True} + strategy_type=self.expected_strategy_type, + extra_args={"upload-only": True, "patch_id": "stx-10.1"}, ) # mock that there is no pre-existing strategy @@ -42,7 +64,7 @@ class TestPatchUpdateStrategy(UpdateStrategyMixin, base.BaseCommandTest): # invoke the backend method for the CLI. # Returns a tuple of field descriptions, and a second tuple of values - fields, results = self.call(self.create_command, ["--upload-only"]) + fields, results = self.call(self.create_command, ["stx-10.1", "--upload-only"]) # results is a tuple of expected length self.assertEqual(len(results), self.results_length) @@ -59,21 +81,3 @@ class TestPatchUpdateStrategy(UpdateStrategyMixin, base.BaseCommandTest): self.assertEqual(results[0], self.expected_strategy_type) self.assertEqual(fields[-4], "upload only") self.assertEqual(results[-4], True) - - def test_create_strategy_patch_file(self): - """Test that a strategy can be created with the --patch option""" - - # mock the result of the API call - strategy = utils.make_strategy(strategy_type=self.expected_strategy_type) - - # mock that there is no pre-existing strategy - self.manager_to_test.create_sw_update_strategy.return_value = strategy - - # invoke the backend method for the CLI. - # Returns a tuple of field descriptions, and a second tuple of values - # with self.assertRaises(argparse.ArgumentError): - _, results = self.call(self.create_command, ["--patch usm.patch"]) - - # results is a tuple of expected length - self.assertEqual(len(results), self.results_length) - self.assertEqual(results[0], self.expected_strategy_type)