def test_sorted_filter_stack(self): ctx = Mock() ctx.parent = {'sort': 'stack_asc'} a = {'type': 'folder', 'sub_folders': [], 'files': []} b = { 'type': 'file', 'symbols': [{ 'type': 'function', 'stack_size': 200 }] } c = { 'type': 'file', 'symbols': [{ 'type': 'function', 'stack_size': 300 }] } actual = renderers.sorted_filter(ctx, [b, c, a]) self.assertEqual([a, b, c], actual) ctx.parent = {'sort': 'stack_desc'} actual = renderers.sorted_filter(ctx, [b, c, a]) self.assertEqual([c, b, a], actual)
def test_sorted_filter_name(self): ctx = Mock() ctx.parent = {'sort': 'name_asc'} a = {'display_name': 'a'} b = {'name': 'b'} c = {'display_name': 'C'} actual = renderers.sorted_filter(ctx, [b, c, a]) self.assertEqual([a, b, c], actual) ctx.parent = {'sort': 'name_desc'} actual = renderers.sorted_filter(ctx, [b, c, a]) self.assertEqual([c, b, a], actual)