def test_get_folders_tree_HTML(self): expected ='''<ul> <li id="1">dum_f_0 <ul> <li id="2">dum_f_0_0_0 <ul> <li id="3">dum_f_0_0_0_1_0 </li> <li id="4">dum_f_0_0_0_1_1 </li> </ul> </li> <li id="5">dum_f_0_0_1 <ul> <li id="6">dum_f_0_0_1_1_0 </li> <li id="7">dum_f_0_0_1_1_1 </li> </ul> </li> </ul> </li> </ul> ''' DummyFolder().create_dummy_catalogue() html = get_folders_tree_HTML(tab='') self.assertEqual(html, expected)
def test_get_folders_tree_HTML(self): expected = '''<ul> <li id="1">dum_f_0 <ul> <li id="2">dum_f_0_0_0 <ul> <li id="3">dum_f_0_0_0_1_0 </li> <li id="4">dum_f_0_0_0_1_1 </li> </ul> </li> <li id="5">dum_f_0_0_1 <ul> <li id="6">dum_f_0_0_1_1_0 </li> <li id="7">dum_f_0_0_1_1_1 </li> </ul> </li> </ul> </li> </ul> ''' DummyFolder().create_dummy_catalogue() html = get_folders_tree_HTML(tab='') self.assertEqual(html, expected)
def ajaxFoldersTreeFromBase(request): if 'client_request' in request.POST: # Формуємо дерево тек у вигляді HTML для роботи jsTree : folderTree = get_folders_tree_HTML() # Посилаємо відповідь клієнту: response_dict = {'server_response': folderTree } # return JsonResponse(response_dict) return HttpResponse(json.dumps(response_dict), content_type="application/json") else: print("There is no 'client_request' in request.POST") return HttpResponse()