diff --git a/tests/test_rubeus.py b/tests/test_rubeus.py index bae64700250..1c3ebb1984c 100644 --- a/tests/test_rubeus.py +++ b/tests/test_rubeus.py @@ -11,6 +11,7 @@ from website.util import rubeus from website.util.rubeus import sort_by_name + class TestRubeus(OsfTestCase): def setUp(self): @@ -316,8 +317,9 @@ def setUp(self): self.serializer = rubeus.NodeFileCollector(node=self.project, auth=self.auth) def test_collect_addons(self): - ret = self.serializer._collect_addons(self.project) - assert_equal(ret, [serialized]) + return_value, active_addons = self.serializer._collect_addons(self.project) + assert_equal(return_value, [serialized]) + assert_equal(len(active_addons), 1) def test_sort_by_name(self): files = [ diff --git a/website/util/rubeus.py b/website/util/rubeus.py index aacda00038a..a2b16067b43 100644 --- a/website/util/rubeus.py +++ b/website/util/rubeus.py @@ -241,6 +241,7 @@ def _serialize_node(self, node, parent=None, grid_root=None, children=None, def _get_nodes(self, node, grid_root=None): data = [] + active_addons = [] if node.can_view(auth=self.auth): serialized_addons, active_addons = self._collect_addons(node) serialized_children = [ @@ -251,18 +252,17 @@ def _get_nodes(self, node, grid_root=None): return self._serialize_node(node, children=data, active_addons=active_addons) def _collect_addons(self, node): - rv = [] + return_value = [] active_addons = [] for addon in node.get_addons(): if addon.has_auth: active_addons.append(addon.config.short_name) - if addon.config.has_hgrid_files: # WARNING: get_hgrid_data can return None if the addon is added but has no credentials. try: temp = addon.config.get_hgrid_data(addon, self.auth, **self.extra) except Exception as e: - logger.warn( + logger.warning( getattr( e, 'data', @@ -270,7 +270,7 @@ def _collect_addons(self, node): ) ) sentry.log_exception() - rv.append({ + return_value.append({ KIND: FOLDER, 'unavailable': True, 'iconUrl': addon.config.icon_url, @@ -280,8 +280,8 @@ def _collect_addons(self, node): 'name': '{} is currently unavailable'.format(addon.config.full_name), }) continue - rv.extend(sort_by_name(temp) or []) - return rv, active_addons + return_value.extend(sort_by_name(temp) or []) + return return_value, active_addons # TODO: these might belong in addons module