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

Revert "Fix error in 'kickstart_delete' when using wildcards (bsc#1227578)" #9296

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion java/code/src/com/suse/utils/Exceptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* in this software or its documentation.
*/
package com.suse.utils;

//TEST
import java.util.Optional;

public final class Exceptions {
Expand Down
2 changes: 0 additions & 2 deletions spacecmd/spacecmd.changes.cbbayburt.bsc1227578

This file was deleted.

14 changes: 10 additions & 4 deletions spacecmd/src/spacecmd/kickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,16 @@ def do_kickstart_delete(self, args):
self.help_kickstart_delete()
return 1

for label in labels:
if self.options.yes or self.user_confirm(_("Delete profile %s [y/N]:") % label):
self.client.kickstart.deleteProfile(self.session, label)
return 0
mismatched = sorted(set(args).difference(set(all_labels)))
if mismatched:
logging.error(_N("The following kickstart labels are invalid:"),
", ".join(mismatched))
return 1
else:
for label in labels:
if self.options.yes or self.user_confirm(_("Delete profile %s [y/N]:") % label):
self.client.kickstart.deleteProfile(self.session, label)
return 0

####################

Expand Down
19 changes: 10 additions & 9 deletions spacecmd/tests/test_kickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,9 +374,9 @@ def test_kickstart_delete_invalid_profile(self, shell):
assert_args_expect(shell.do_kickstart_list.call_args_list,
[(('', True), {})])

def test_kickstart_delete_wildcard_arg(self, shell):
def test_kickstart_delete_some_invalid_profile(self, shell):
"""
Test do_kickstart_delete with a wildcard argument
Test do_kickstart_delete invalid profile (not found).

:param shell:
:return:
Expand All @@ -387,18 +387,19 @@ def test_kickstart_delete_wildcard_arg(self, shell):
logger = MagicMock()
with patch("spacecmd.kickstart.logging", logger) as lgr:
spacecmd.kickstart.do_kickstart_delete(
shell, "*_profile")
shell, "fourth_profile zero_profile first_profile second_profile")

assert not shell.client.kickstart.deleteProfile.called
assert not shell.help_kickstart_delete.called
assert not logger.error.called
assert shell.client.kickstart.deleteProfile.called
assert logger.error.called
assert shell.do_kickstart_list.called
assert logger.debug.called

assert_args_expect(shell.client.kickstart.deleteProfile.call_args_list,
[((shell.session, "first_profile"), {}),
((shell.session, "second_profile"), {}),
((shell.session, "third_profile"), {})])
assert_expect(logger.debug.call_args_list,
"Got labels to delete of ['first_profile', 'second_profile']")
assert_args_expect(logger.error.call_args_list,
[(('The following kickstart labels are invalid:',
'fourth_profile, zero_profile'), {})])

def test_kickstart_delete_profile_all_yes(self, shell):
"""
Expand Down
Loading