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

Add force default location #641

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
26 changes: 26 additions & 0 deletions tests/large/test_baseinstaller.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,32 @@ def test_default_install(self):
self.child.sendline()
self.wait_and_close()

def test_default_path_install(self):
"""Install base installer from scratch test case in default path"""
self.child = spawn_process(self.command('{} base base-framework -f'.format(UMAKE)))
self.expect_and_no_warn(r"\[I Accept.*\]") # ensure we have a license question
self.child.sendline("a")
self.expect_and_no_warn("Installation done", timeout=self.TIMEOUT_INSTALL_PROGRESS)
self.wait_and_close()

# we have an installed launcher, added to the launcher
self.assertTrue(self.launcher_exists_and_is_pinned(self.desktop_filename))
self.assert_exec_exists()
self.assert_icon_exists()
self.assert_exec_link_exists()

# launch it, send SIGTERM and check that it exits fine
proc = subprocess.Popen(self.command_as_list(self.exec_path), stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL)
self.check_and_kill_process([self.JAVAEXEC, self.installed_path], wait_before=self.TIMEOUT_START)
self.assertEqual(proc.wait(self.TIMEOUT_STOP), 143)

# ensure that it's detected as installed:
self.child = spawn_process(self.command('{} base base-framework'.format(UMAKE)))
self.expect_and_no_warn(r"Base Framework is already installed.*\[.*\] ")
self.child.sendline()
self.wait_and_close()

def test_no_license_accept(self):
"""We don't accept the license (default)"""
self.child = spawn_process(self.command('{} base base-framework'.format(UMAKE)))
Expand Down
17 changes: 13 additions & 4 deletions tests/small/test_frameworks_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,13 +296,15 @@ def test_parse_category_and_framework_run_correct_framework(self):
args.destdir = None
args.framework = "framework-b"
args.accept_license = False
args.force = False
args.remove = False
with patch.object(self.CategoryHandler.categories[args.category].frameworks["framework-b"], "setup")\
as setup_call:
self.CategoryHandler.categories[args.category].run_for(args)

self.assertTrue(setup_call.called)
self.assertEqual(setup_call.call_args, call(install_path=None, auto_accept_license=False))
self.assertEqual(setup_call.call_args, call(force_defaults=False,
install_path=None,
auto_accept_license=False))

def test_parse_no_framework_run_default_for_category(self):
"""Parsing category will run default framework"""
Expand All @@ -311,12 +313,15 @@ def test_parse_no_framework_run_default_for_category(self):
args.destdir = None
args.framework = None
args.accept_license = False
args.force = False
args.remove = False
with patch.object(self.CategoryHandler.categories[args.category].frameworks["framework-a"], "setup")\
as setup_call:
self.CategoryHandler.categories[args.category].run_for(args)
self.assertTrue(setup_call.called)
self.assertEqual(setup_call.call_args, call(install_path=None, auto_accept_license=False))
self.assertEqual(setup_call.call_args, call(force_defaults=False,
install_path=None,
auto_accept_license=False))

def test_parse_category_and_framework_run_correct_remove_framework(self):
"""Parsing category and framework with --remove run remove on right category and framework"""
Expand Down Expand Up @@ -376,6 +381,7 @@ def test_parse_category_and_framework_cannot_install_not_installable_but_install
args.destdir = None
args.framework = "framework-r-installed-not-installable"
args.accept_license = False
args.force = False
args.remove = False
self.assertRaises(BaseException, self.CategoryHandler.categories[args.category].run_for, args)

Expand All @@ -401,13 +407,16 @@ def test_parse_category_and_framework_get_accept_license_arg(self):
args.destdir = None
args.framework = "framework-b"
args.accept_license = True
args.force = False
args.remove = False
with patch.object(self.CategoryHandler.categories[args.category].frameworks["framework-b"], "setup")\
as setup_call:
self.CategoryHandler.categories[args.category].run_for(args)

self.assertTrue(setup_call.called)
self.assertEqual(setup_call.call_args, call(install_path=None, auto_accept_license=True))
self.assertEqual(setup_call.call_args, call(force_defaults=False,
install_path=None,
auto_accept_license=True))

def test_uninstantiable_framework(self):
"""A uninstantiable framework isn't loaded"""
Expand Down
6 changes: 4 additions & 2 deletions umake/frameworks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,8 @@ def install_framework_parser(self, parser):
help=_("Remove framework if installed"))
this_framework_parser.add_argument('--dry-run', dest="dry_run", action="store_true",
help=_("Fetch only the url, then exit."))

this_framework_parser.add_argument('-f', '--force', action="store_true",
help=_("Force install with defaults"))
if self.expect_license:
this_framework_parser.add_argument('--accept-license', dest="accept_license", action="store_true",
help=_("Accept license without prompting"))
Expand All @@ -329,7 +330,8 @@ def run_for(self, args):
dry_run = True
self.setup(install_path=install_path,
auto_accept_license=auto_accept_license,
dry_run=dry_run)
dry_run=dry_run,
force_defaults=args.force)


class MainCategory(BaseCategory):
Expand Down
9 changes: 7 additions & 2 deletions umake/frameworks/baseinstaller.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ def is_installed(self):
logger.debug("{} is installed".format(self.name))
return True

def setup(self, install_path=None, auto_accept_license=False, dry_run=False):
def setup(self, install_path=None, auto_accept_license=False, dry_run=False, force_defaults=False):
self.force_defaults = force_defaults
self.arg_install_path = install_path
self.auto_accept_license = auto_accept_license
self.dry_run = dry_run
Expand All @@ -110,7 +111,7 @@ def setup(self, install_path=None, auto_accept_license=False, dry_run=False):
# first step, check if installed or dry_run
if self.dry_run:
self.download_provider_page()
elif self.is_installed:
elif self.is_installed and not self.force_defaults:
UI.display(YesNo("{} is already installed on your system, do you want to reinstall "
"it anyway?".format(self.name), self.reinstall, UI.return_main_screen))
else:
Expand Down Expand Up @@ -162,6 +163,10 @@ def confirm_path(self, path_dir=""):
"""Confirm path dir"""

if not path_dir:
if self.force_defaults:
path_dir = self.install_path
self.set_installdir_to_clean()
return
logger.debug("No installation path provided. Requesting one.")
UI.display(InputText("Choose installation path:", self.confirm_path, self.install_path))
return
Expand Down