Skip to content

Commit 05b94f8

Browse files
committed
Move depends def and add test
1 parent 078699e commit 05b94f8

File tree

4 files changed

+42
-0
lines changed

4 files changed

+42
-0
lines changed

tests/small/test_frameworks_loader.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,22 @@ def test_parse_no_framework_run_default_for_category(self):
318318
self.assertTrue(setup_call.called)
319319
self.assertEqual(setup_call.call_args, call(install_path=None, auto_accept_license=False))
320320

321+
def test_parse_category_and_framework_list_dependencies(self):
322+
"""Parsing category will run default framework"""
323+
args = Mock()
324+
args.category = "category-a"
325+
args.destdir = None
326+
args.framework = "framework-b"
327+
args.depends = True
328+
args.accept_license = False
329+
args.remove = False
330+
with patch.object(self.CategoryHandler.categories[args.category].frameworks["framework-a"], "depends")\
331+
as depends_call:
332+
self.CategoryHandler.categories[args.category].run_for(args)
333+
self.assertTrue(depends_call.called)
334+
remove_call.assert_called_with()
335+
# self.assertEqual(setup_call.call_args, call(install_path=None, auto_accept_license=False))
336+
321337
def test_parse_category_and_framework_run_correct_remove_framework(self):
322338
"""Parsing category and framework with --remove run remove on right category and framework"""
323339
args = Mock()

umake/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ def main():
132132
parser.add_argument("-v", "--verbose", action="count", default=0, help=_("Increase output verbosity (2 levels)"))
133133

134134
parser.add_argument('-r', '--remove', action="store_true", help=_("Remove specified framework if installed"))
135+
parser.add_argument('-d', '--depends', action="store_true", help=_("List specified framework dependencies"))
135136

136137
list_group = parser.add_argument_group("List frameworks").add_mutually_exclusive_group()
137138
list_group.add_argument('-l', '--list', action="store_true", help=_("List all frameworks"))

umake/frameworks/__init__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
from umake.settings import DEFAULT_INSTALL_TOOLS_PATH, UMAKE_FRAMEWORKS_ENVIRON_VARIABLE, DEFAULT_BINARY_LINK_PATH
3535
from umake.tools import ConfigHandler, NoneDict, classproperty, get_current_arch, get_current_distro_version,\
3636
is_completion_mode, switch_to_current_user, MainLoop, get_user_frameworks_path, get_current_distro_id
37+
from umake.interactions import DisplayMessage
3738
from umake.ui import UI
3839

3940

@@ -263,6 +264,13 @@ def setup(self):
263264
# be a normal, kind user as we don't want normal files to be written as root
264265
switch_to_current_user()
265266

267+
@abc.abstractmethod
268+
def depends(self):
269+
"""Method call to list depends for current framework"""
270+
if not self.is_installable:
271+
logger.error(_("Framework {} is not installable".format(self.name)))
272+
UI.return_main_screen(status_code=2)
273+
266274
@abc.abstractmethod
267275
def remove(self):
268276
"""Method call to remove the current framework"""
@@ -300,6 +308,8 @@ def install_framework_parser(self, parser):
300308
"destdir should contain a /"))
301309
this_framework_parser.add_argument('-r', '--remove', action="store_true",
302310
help=_("Remove framework if installed"))
311+
this_framework_parser.add_argument('-d', '--depends', action="store_true",
312+
help=_("List dependencies"))
303313
if self.expect_license:
304314
this_framework_parser.add_argument('--accept-license', dest="accept_license", action="store_true",
305315
help=_("Accept license without prompting"))
@@ -314,6 +324,12 @@ def run_for(self, args):
314324
logger.error(message)
315325
UI.return_main_screen(status_code=2)
316326
self.remove()
327+
if args.depends:
328+
if args.destdir:
329+
message = "You can't specify a destination dir while listing framework dependencies"
330+
logger.error(message)
331+
UI.return_main_screen(status_code=2)
332+
self.depends()
317333
else:
318334
install_path = None
319335
auto_accept_license = False

umake/frameworks/baseinstaller.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,15 @@ def reinstall(self):
119119
self.confirm_path(self.arg_install_path)
120120
remove_framework_envs_from_user(self.name)
121121

122+
def depends(self):
123+
"""List necessary apt dependencies"""
124+
if not self.need_root_access:
125+
UI.display(DisplayMessage("Required packages are installed"))
126+
else:
127+
UI.display(DisplayMessage("Required packages will be installed"))
128+
UI.display(DisplayMessage(' '.join(self.packages_requirements)))
129+
UI.return_main_screen(status_code=0)
130+
122131
def remove(self):
123132
"""Remove current framework if installed
124133

0 commit comments

Comments
 (0)