def test_tree_from_list3(self): rows = [{'name': 'parent_name', 'parent': None}, {'name': 'child_name', 'parent': 'parent_name'}, {'name': 'child_name2', 'parent': 'parent_name'}, {'name': 'child_name3', 'parent': 'parent_name'}, {'name': 'child_child', 'parent': 'child_name3'}] result_good = [ {'name': 'parent_name', 'parent': None, 'children': [ {'name': 'child_name', 'parent': 'parent_name', 'children': []}, {'name': 'child_name2', 'parent': 'parent_name', 'children': []}, {'name': 'child_name3', 'parent': 'parent_name', 'children': [ {'name': 'child_child', 'parent': 'child_name3', 'children': []}]}, ]}] result_function = tree_from_list( rows, id_field='name', parent_field='parent', children_field='children', root_parent=None) self.assertEqual(result_function, result_good)
def test_tree_from_list1(self): rows = [] result_good = [] result_function = tree_from_list(rows) self.assertEqual(result_function, result_good)
url = reverse(url_name, kwargs={'jdbc_source_slug': self.slug}) url += '?filter_id=%s' % named_filter['id'] # There used to be a line here that added # 'ignore_cache=True' to the URL if ignore_cache # is true. However, the variable controls whether # we currently ignore the cache, not whether the # URLs we build ignore it. In normal # circumstances, the cache should not be ignored. named_filter['url'] = url # Make the tree. filter_tree = tree_from_list( named_filters, id_field='id', parent_field='parentid', children_field='children', root_parent=root_parent) cache.set(filter_source_cache_key, filter_tree, cache_timeout) return filter_tree def get_named_parameters(self, filter_id, ignore_cache=False, find_lowest=True, url_name='lizard_fewsjdbc.jdbc_source', cache_timeout=CACHE_TIMEOUT): """ Get named parameters given filter_id: [{'name': <filter>, 'parameterid': <parameterid1>, 'parameter': <parameter1>}, ...]