def test_show_node_view(self): response = self.client.get(portal_url(portal=get_portal())) self.assertContains(response, 'a05e') response = self.client.get( portal_url(portal=get_portal(), path='child1')) self.assertContains(response, 'b864')
def test_show_node_view(self): response = self.client.get(portal_url(portal=get_portal())) self.assertContains(response, 'a05e') response = self.client.get(portal_url(portal=get_portal(), path='child1')) self.assertContains(response, 'b864')
def test_edit_node_view(self): self.client.login(username='******') node = get_portal().root.children.get(short_name='child2') response = self.client.post(portal_url(node=node, action='edit_node'), data={ 'full_name': '81dc', 'short_name': 'child1', 'panel_code': 'e10a' }) self.assertEqual(response.status_code, 200) root = get_portal().root self.assertQuerysetEqual(root.get_children(), ['<Node: Child 1>', '<Node: Child 2>']) response = self.client.post(portal_url(portal=get_portal(), action='edit_node'), data={ 'full_name': 'b40d', 'panel_code': 'e23f' }) self.assertRedirects(response, portal_url(portal=get_portal())) node = get_portal().root self.assertEqual(node.full_name, 'b40d') self.assertEqual(node.panel_code, 'e23f')
def test_admin_access(self): def assertAdminAccess(url): self.client.logout() response = self.client.get(url) self.assertEqual(response.status_code, 403) self.assertTrue(self.client.login(username='******')) response = self.client.get(url) self.assertEqual(response.status_code, 200) self.assertTrue(self.client.login(username='******')) response = self.client.get(url) self.assertEqual(response.status_code, 403) self.assertTrue(self.client.login(username='******')) response = self.client.get(url) self.assertEqual(response.status_code, 200) for action in ('edit_node', 'add_node', 'delete_node'): assertAdminAccess(portal_url(portal=get_portal(), path='child1', action=action)) for action in ('manage_portal', 'portal_tree_json', 'delete_portal'): assertAdminAccess(portal_url(portal=get_portal(), action=action))
def test_add_node_view(self): self.client.login(username='******') root = get_portal().root response = self.client.post(portal_url(node=root, action='add_node'), data={ 'full_name': '3e4a', 'short_name': 'child1', 'panel_code': '5ac3' }) self.assertEqual(response.status_code, 200) self.assertQuerysetEqual(root.get_children(), ['<Node: Child 1>', '<Node: Child 2>']) response = self.client.post(portal_url(portal=get_portal(), path='child2', action='add_node'), data={ 'short_name': 'grandchild2', 'full_name': 'Grandchild 2', 'panel_code': '18e0' }) self.assertRedirects( response, portal_url(portal=get_portal(), path='child2/grandchild2')) node = get_portal().root.children.get(short_name='child2') self.assertEqual(node.children.count(), 1) node = node.children.get() self.assertEqual(node.short_name, 'grandchild2') self.assertEqual(node.full_name, 'Grandchild 2') self.assertEqual(node.panel_code, '18e0')
def test_add_node_view(self): self.client.login(username='******') root = get_portal().root response = self.client.post(portal_url(node=root, action='add_node'), data={'full_name': '3e4a', 'short_name': 'child1', 'panel_code': '5ac3'}) self.assertEqual(response.status_code, 200) self.assertQuerysetEqual(root.get_children(), ['<Node: Child 1>', '<Node: Child 2>']) response = self.client.post(portal_url(portal=get_portal(), path='child2', action='add_node'), data={'short_name': 'grandchild2', 'full_name': 'Grandchild 2', 'panel_code': '18e0'}) self.assertRedirects(response, portal_url(portal=get_portal(), path='child2/grandchild2')) node = get_portal().root.children.get(short_name='child2') self.assertEqual(node.children.count(), 1) node = node.children.get() self.assertEqual(node.short_name, 'grandchild2') self.assertEqual(node.full_name, 'Grandchild 2') self.assertEqual(node.panel_code, '18e0')
def test_admin_access(self): def assertAdminAccess(url): self.client.logout() response = self.client.get(url) self.assertEquals(response.status_code, 403) self.client.login(username='******') response = self.client.get(url) self.assertEquals(response.status_code, 200) self.client.login(username='******') response = self.client.get(url) self.assertEquals(response.status_code, 403) self.client.login(username='******') response = self.client.get(url) self.assertEquals(response.status_code, 200) for action in ('edit_node', 'add_node', 'delete_node'): assertAdminAccess(portal_url(portal=get_portal(), path='child1', action=action)) for action in ('manage_portal', 'portal_tree_json', 'delete_portal'): assertAdminAccess(portal_url(portal=get_portal(), action=action))
def delete_node_view(request): if request.method != 'POST': return render(request, 'portals/delete-node.html') else: if 'confirmation' in request.POST: parent = request.current_node.parent request.current_node.delete() return redirect(portal_url(node=parent)) else: return redirect(portal_url(node=request.current_node))
def test_add_node_view(self): self.assertTrue(self.client.login(username='******')) root = get_portal().root response = self.client.post(portal_url(node=root, action='add_node'), data={ 'short_name': 'child1', 'language_versions-0-id': '', 'language_versions-0-full_name': '3e4a', 'language_versions-0-panel_code': '5ac3', 'language_versions-0-language': 'en', 'language_versions-MAX_NUM_FORMS': 1, 'language_versions-TOTAL_FORMS': 1, 'language_versions-MIN_NUM_FORMS': 1, 'language_versions-INITIAL_FORMS': 0, }) self.assertEqual(response.status_code, 200) self.assertQuerysetEqual(root.get_children(), ['<Node: Child 1>', '<Node: Child 2>']) response = self.client.post(portal_url(portal=get_portal(), path='child2', action='add_node'), data={ 'short_name': 'grandchild2', 'language_versions-0-id': '', 'language_versions-0-full_name': 'Grandchild 2', 'language_versions-0-panel_code': '18e0', 'language_versions-0-language': 'en', 'language_versions-MAX_NUM_FORMS': 1, 'language_versions-TOTAL_FORMS': 1, 'language_versions-MIN_NUM_FORMS': 1, 'language_versions-INITIAL_FORMS': 0, }) self.assertRedirects( response, portal_url(portal=get_portal(), path='child2/grandchild2')) node = get_portal().root.children.get(short_name='child2') self.assertEqual(node.children.count(), 1) node = node.children.get() self.assertEqual(node.short_name, 'grandchild2') self.assertEqual( node.language_versions.get(language='en').full_name, 'Grandchild 2') self.assertEqual( node.language_versions.get(language='en').panel_code, '18e0')
def add_node_view(request): if request.method != 'POST': form = NodeForm(initial={'parent': request.current_node}) current_language = get_language_from_request(request) formset = NodeLanguageVersionFormset( initial=[{ 'language': lang_short, 'DELETE': lang_short != current_language } for lang_short, lang_name in settings.LANGUAGES], queryset=NodeLanguageVersion.objects.none(), ) else: instance = Node(parent=request.current_node) form = NodeForm(request.POST, instance=instance) formset = NodeLanguageVersionFormset(request.POST) if form.is_valid(): node = form.save(commit=False) formset = NodeLanguageVersionFormset(request.POST, instance=node) if formset.is_valid(): node.save() formset.save() return redirect(portal_url(node=node)) return render(request, 'portals/add-node.html', { 'form': form, 'formset': formset, })
def test_portal_tree_json_view(self): self.client.login(username='******') response = self.client.get(portal_url(portal=get_portal(), action='portal_tree_json')) self.assertJSONEqual(response.content, ''' [ { "id": 1, "short_name": "", "label": "Root", "children": [ { "id": 2, "short_name": "child1", "label": "Child 1", "children": [ { "id": 4, "short_name": "grandchild1", "label": "Grandchild 1", "children": [] } ] }, { "id": 3, "short_name": "child2", "label": "Child 2", "children": [] } ] } ] ''')
def create_global_portal_view(request): if request.method == 'POST': form = LinkNameForm(request.POST) if 'confirmation' in request.POST: if form.is_valid(): name = render_to_string( 'portals/global-portal-initial-main-page-name.txt') body = render_to_string( 'portals/global-portal-initial-main-page-body.txt') root = Node.objects.create(short_name='', parent=None) lang = get_language_from_request(request) NodeLanguageVersion.objects.create(language=lang, full_name=name, panel_code=body, node=root) portal = Portal(owner=None, root=root) form = LinkNameForm(request.POST, instance=portal) form.save() return redirect(portal_url(portal=portal)) else: return redirect( reverse('portals_main_page_type', kwargs={'view_type': 'global'})) else: form = LinkNameForm() return render(request, 'portals/create-global-portal.html', {'form': form})
def add_node_view(request): if request.method != 'POST': form = NodeForm(initial={'parent': request.current_node}) current_language = get_language_from_request(request) formset = NodeLanguageVersionFormset( initial=[ { 'language': lang_short, 'DELETE': lang_short != current_language } for lang_short, lang_name in settings.LANGUAGES ], queryset=NodeLanguageVersion.objects.none(), ) else: instance = Node(parent=request.current_node) form = NodeForm(request.POST, instance=instance) formset = NodeLanguageVersionFormset(request.POST) if form.is_valid(): node = form.save(commit=False) formset = NodeLanguageVersionFormset(request.POST, instance=node) if formset.is_valid(): node.save() formset.save() return redirect(portal_url(node=node)) return render(request, 'portals/add-node.html', { 'form': form, 'formset': formset, })
def test_portal_tree_json_view(self): self.assertTrue(self.client.login(username='******')) response = self.client.get( portal_url(portal=get_portal(), action='portal_tree_json')) self.assertJSONEqual( response.content.decode('utf-8'), ''' [ { "id": 1, "short_name": "", "label": "Root", "children": [ { "id": 2, "short_name": "child1", "label": "Child 1", "children": [ { "id": 4, "short_name": "grandchild1", "label": "Grandchild 1", "children": [] } ] }, { "id": 3, "short_name": "child2", "label": "Child 2", "children": [] } ] } ] ''')
def create_global_portal_view(request): if request.method == 'POST': form = LinkNameForm(request.POST) if 'confirmation' in request.POST: if form.is_valid(): name = render_to_string( 'portals/global-portal-initial-main-page-name.txt') body = render_to_string( 'portals/global-portal-initial-main-page-body.txt') root = Node.objects.create(short_name='', parent=None) lang = get_language_from_request(request) NodeLanguageVersion.objects.create(language=lang, full_name=name, panel_code=body, node=root) portal = Portal(owner=None, root=root) form = LinkNameForm(request.POST, instance=portal) form.save() return redirect(portal_url(portal=portal)) else: return redirect(reverse('portals_main_page_type', kwargs={'view_type': 'global'})) else: form = LinkNameForm() return render(request, 'portals/create-global-portal.html', {'form': form})
def test_delete_node_view(self): self.assertTrue(self.client.login(username='******')) response = self.client.post(portal_url(portal=get_portal(), path='child1', action='delete_node')) self.assertRedirects(response, portal_url(portal=get_portal(), path='child1')) response = self.client.post(portal_url(portal=get_portal(), path='child1', action='delete_node'), data={'confirmation': ''}) self.assertRedirects(response, portal_url(portal=get_portal())) node = get_portal().root self.assertQuerysetEqual(node.get_children(), ['<Node: Child 2>'])
def test_delete_node_view(self): self.client.login(username='******') response = self.client.post(portal_url(portal=get_portal(), path='child1', action='delete_node')) self.assertRedirects(response, portal_url(portal=get_portal(), path='child1')) response = self.client.post(portal_url(portal=get_portal(), path='child1', action='delete_node'), data={'confirmation': ''}) self.assertRedirects(response, portal_url(portal=get_portal())) node = get_portal().root self.assertQuerysetEqual(node.get_children(), ['<Node: Child 2>'])
def test_delete_portal_view(self): self.client.login(username='******') response = self.client.post( portal_url(portal=get_portal(), action='delete_portal')) self.assertRedirects( response, portal_url(portal=get_portal(), action='manage_portal')) response = self.client.post(portal_url(portal=get_portal(), action='delete_portal'), data={'confirmation': ''}) self.assertRedirects(response, '/', target_status_code=302) with self.assertRaises(Portal.DoesNotExist): Portal.objects.get(owner__username='******') with self.assertRaises(Node.DoesNotExist): Node.objects.get(pk=1)
def test_delete_portal_view(self): self.client.login(username='******') response = self.client.post(portal_url(portal=get_portal(), action='delete_portal')) self.assertRedirects(response, portal_url(portal=get_portal(), action='manage_portal')) response = self.client.post(portal_url(portal=get_portal(), action='delete_portal'), data={'confirmation': ''}) self.assertRedirects(response, '/', target_status_code=302) with self.assertRaises(Portal.DoesNotExist): Portal.objects.get(owner__username='******') with self.assertRaises(Node.DoesNotExist): Node.objects.get(pk=1)
def test_edit_node_view(self): self.assertTrue(self.client.login(username='******')) node = get_portal().root.children.get(short_name='child2') response = self.client.post(portal_url(node=node, action='edit_node'), data={ 'short_name': 'child1', 'language_versions-0-id': '', 'language_versions-0-full_name': '81dc', 'language_versions-0-panel_code': 'e10a', 'language_versions-0-language': 'en', 'language_versions-MAX_NUM_FORMS': 1, 'language_versions-TOTAL_FORMS': 1, 'language_versions-MIN_NUM_FORMS': 1, 'language_versions-INITIAL_FORMS': 0, }) self.assertEqual(response.status_code, 200) root = get_portal().root self.assertQuerysetEqual(root.get_children(), ['<Node: Child 1>', '<Node: Child 2>']) response = self.client.post(portal_url(portal=get_portal(), action='edit_node'), data={ 'language_versions-0-id': '1', 'language_versions-0-full_name': 'b40d', 'language_versions-0-panel_code': 'e23f', 'language_versions-0-language': 'en', 'language_versions-0-node': '1', 'language_versions-MAX_NUM_FORMS': 1, 'language_versions-TOTAL_FORMS': 1, 'language_versions-MIN_NUM_FORMS': 1, 'language_versions-INITIAL_FORMS': 1, }) self.assertRedirects(response, portal_url(portal=get_portal())) node = get_portal().root self.assertEqual( node.language_versions.get(language='en').full_name, 'b40d') self.assertEqual( node.language_versions.get(language='en').panel_code, 'e23f')
def create_user_portal_view(request): portal_queryset = Portal.objects.filter(owner=request.user) if portal_queryset.exists(): return redirect(portal_url(portal=portal_queryset.get())) if request.method != 'POST': return render(request, 'portals/create-user-portal.html') else: if 'confirmation' in request.POST: name = render_to_string( 'portals/user-portal-initial-main-page-name.txt') body = render_to_string( 'portals/user-portal-initial-main-page-body.txt') root = Node.objects.create(full_name=name, short_name='', parent=None, panel_code=body) portal = Portal.objects.create(owner=request.user, root=root) return redirect(portal_url(portal=portal)) else: return redirect('/')
def edit_node_view(request): if request.method != 'POST': form = NodeForm(instance=request.current_node) else: form = NodeForm(request.POST, instance=request.current_node) if form.is_valid(): node = form.save() return redirect(portal_url(node=node)) return render(request, 'portals/edit-node.html', {'form': form})
def test_add_node_view(self): self.assertTrue(self.client.login(username='******')) root = get_portal().root response = self.client.post( portal_url(node=root, action='add_node'), data={'short_name': 'child1', 'language_versions-0-id': '', 'language_versions-0-full_name': '3e4a', 'language_versions-0-panel_code': '5ac3', 'language_versions-0-language': 'en', 'language_versions-MAX_NUM_FORMS': 1, 'language_versions-TOTAL_FORMS': 1, 'language_versions-MIN_NUM_FORMS': 1, 'language_versions-INITIAL_FORMS': 0, } ) self.assertEqual(response.status_code, 200) self.assertQuerysetEqual(root.get_children(), ['<Node: Child 1>', '<Node: Child 2>']) response = self.client.post( portal_url(portal=get_portal(), path='child2', action='add_node'), data={'short_name': 'grandchild2', 'language_versions-0-id': '', 'language_versions-0-full_name': 'Grandchild 2', 'language_versions-0-panel_code': '18e0', 'language_versions-0-language': 'en', 'language_versions-MAX_NUM_FORMS': 1, 'language_versions-TOTAL_FORMS': 1, 'language_versions-MIN_NUM_FORMS': 1, 'language_versions-INITIAL_FORMS': 0, } ) self.assertRedirects(response, portal_url(portal=get_portal(), path='child2/grandchild2')) node = get_portal().root.children.get(short_name='child2') self.assertEqual(node.children.count(), 1) node = node.children.get() self.assertEqual(node.short_name, 'grandchild2') self.assertEqual( node.language_versions.get(language='en').full_name, 'Grandchild 2') self.assertEqual( node.language_versions.get(language='en').panel_code, '18e0')
def delete_portal_view(request): if request.method != 'POST': return render(request, 'portals/delete-portal.html') else: if 'confirmation' in request.POST: request.portal.root.delete() request.portal.delete() return redirect(reverse('portals_main_page')) else: return redirect(portal_url(portal=request.portal, action='manage_portal'))
def delete_portal_view(request): if request.method != 'POST': return render(request, 'portals/delete-portal.html') else: if 'confirmation' in request.POST: request.portal.root.delete() request.portal.delete() return redirect('/') else: return redirect(portal_url(portal=request.portal, action='manage_portal'))
def add_node_view(request): if request.method != 'POST': form = NodeForm(initial={'parent': request.current_node}) else: instance = Node(parent=request.current_node) form = NodeForm(request.POST, instance=instance) if form.is_valid(): node = form.save() return redirect(portal_url(node=node)) return render(request, 'portals/add-node.html', {'form': form})
def create_user_portal_view(request): portal_queryset = Portal.objects.filter(owner=request.user) if portal_queryset.exists(): return redirect(portal_url(portal=portal_queryset.get())) if request.method != 'POST': return render(request, 'portals/create-user-portal.html') else: if 'confirmation' in request.POST: name = render_to_string('portals/user-portal-initial-main-page-name.txt') body = render_to_string('portals/user-portal-initial-main-page-body.txt') lang = get_language_from_request(request) root = Node.objects.create(short_name='', parent=None) NodeLanguageVersion.objects.create( language=lang, full_name=name, panel_code=body, node=root ) portal = Portal.objects.create(owner=request.user, root=root) return redirect(portal_url(portal=portal)) else: return redirect(reverse('portals_main_page'))
def assertAdminButtons(username, path, buttons): if username is not None: self.client.login(username=username) else: self.client.logout() response = self.client.get(portal_url(portal=get_portal(), path=path)) for button in buttons: self.assertContains(response, button) for button in all - buttons: self.assertNotContains(response, button)
def assertAdminButtons(username, path, buttons): if username is not None: self.assertTrue(self.client.login(username=username)) else: self.client.logout() response = self.client.get( portal_url(portal=get_portal(), path=path)) for button in buttons: self.assertContains(response, button) for button in all - buttons: self.assertNotContains(response, button)
def test_edit_node_view(self): self.client.login(username='******') node = get_portal().root.children.get(short_name='child2') response = self.client.post(portal_url(node=node, action='edit_node'), data={'full_name': '81dc', 'short_name': 'child1', 'panel_code': 'e10a'}) self.assertEqual(response.status_code, 200) root = get_portal().root self.assertQuerysetEqual(root.get_children(), ['<Node: Child 1>', '<Node: Child 2>']) response = self.client.post(portal_url(portal=get_portal(), action='edit_node'), data={'full_name': 'b40d', 'panel_code': 'e23f'}) self.assertRedirects(response, portal_url(portal=get_portal())) node = get_portal().root self.assertEqual(node.full_name, 'b40d') self.assertEqual(node.panel_code, 'e23f')
def test_edit_node_view(self): self.assertTrue(self.client.login(username='******')) node = get_portal().root.children.get(short_name='child2') response = self.client.post( portal_url(node=node, action='edit_node'), data={'short_name': 'child1', 'language_versions-0-id': '', 'language_versions-0-full_name': '81dc', 'language_versions-0-panel_code': 'e10a', 'language_versions-0-language': 'en', 'language_versions-MAX_NUM_FORMS': 1, 'language_versions-TOTAL_FORMS': 1, 'language_versions-MIN_NUM_FORMS': 1, 'language_versions-INITIAL_FORMS': 0, } ) self.assertEqual(response.status_code, 200) root = get_portal().root self.assertQuerysetEqual(root.get_children(), ['<Node: Child 1>', '<Node: Child 2>']) response = self.client.post( portal_url(portal=get_portal(), action='edit_node'), data={'language_versions-0-id': '1', 'language_versions-0-full_name': 'b40d', 'language_versions-0-panel_code': 'e23f', 'language_versions-0-language': 'en', 'language_versions-0-node': '1', 'language_versions-MAX_NUM_FORMS': 1, 'language_versions-TOTAL_FORMS': 1, 'language_versions-MIN_NUM_FORMS': 1, 'language_versions-INITIAL_FORMS': 1, } ) self.assertRedirects(response, portal_url(portal=get_portal())) node = get_portal().root self.assertEqual( node.language_versions.get(language='en').full_name, 'b40d') self.assertEqual( node.language_versions.get(language='en').panel_code, 'e23f')
def create_user_portal_view(request): portal_queryset = Portal.objects.filter(owner=request.user) if portal_queryset.exists(): return redirect(portal_url(portal=portal_queryset.get())) if request.method != 'POST': return render(request, 'portals/create-user-portal.html') else: if 'confirmation' in request.POST: name = render_to_string( 'portals/user-portal-initial-main-page-name.txt') body = render_to_string( 'portals/user-portal-initial-main-page-body.txt') lang = get_language_from_request(request) root = Node.objects.create(short_name='', parent=None) NodeLanguageVersion.objects.create(language=lang, full_name=name, panel_code=body, node=root) portal = Portal.objects.create(owner=request.user, root=root) return redirect(portal_url(portal=portal)) else: return redirect(reverse('portals_main_page'))
def edit_node_view(request): if request.method != 'POST': current_language = get_language_from_request(request) languages = [lang_short for lang_short, _ in settings.LANGUAGES] queryset = NodeLanguageVersion.objects.filter( node=request.current_node) for node_language_version in queryset: languages.remove(node_language_version.language) formset = NodeLanguageVersionFormset( initial=[{ 'language': lang, 'DELETE': lang != current_language } for lang in languages], instance=request.current_node, ) form = NodeForm(instance=request.current_node) else: form = NodeForm(request.POST, instance=request.current_node) formset = NodeLanguageVersionFormset(request.POST) if form.is_valid(): node = form.save(commit=False) formset = NodeLanguageVersionFormset(request.POST, instance=node) if formset.is_valid(): node.save() formset.save() return redirect(portal_url(node=node)) return render( request, 'portals/edit-node.html', { 'form': form, 'formset': formset, }, )
def edit_node_view(request): if request.method != 'POST': current_language = get_language_from_request(request) languages = [ lang_short for lang_short, lang_name in settings.LANGUAGES ] queryset = NodeLanguageVersion.objects.filter( node=request.current_node) for node_language_version in queryset: languages.remove(node_language_version.language) formset = NodeLanguageVersionFormset( initial=[ {'language': lang, 'DELETE': lang != current_language} for lang in languages ], instance=request.current_node, ) form = NodeForm(instance=request.current_node) else: form = NodeForm(request.POST, instance=request.current_node) formset = NodeLanguageVersionFormset(request.POST) if form.is_valid(): node = form.save(commit=False) formset = NodeLanguageVersionFormset(request.POST, instance=node) if formset.is_valid(): node.save() formset.save() return redirect(portal_url(node=node)) return render(request, 'portals/edit-node.html', { 'form': form, 'formset': formset, })
def test_portal_url(self): portal = get_portal() root = portal.root child1 = root.children.get(short_name='child1') url = '/~test_user/' self.assertEqual(portal_url(portal=portal), url) self.assertEqual(portal_url(portal=portal, path=''), url) self.assertEqual(portal_url(node=root), url) url = '/~test_user/child1' self.assertEqual(portal_url(portal=portal, path='child1'), url) self.assertEqual(portal_url(node=child1), url) self.assertEqual(portal_url(node=child1, action='show_node'), url) self.assertEqual(portal_url(node=child1, action='edit_node'), url + '?action=edit_node') url = '/~test_user/?action=manage_portal' self.assertEqual(portal_url(portal=portal, action='manage_portal'), url) portal = Portal.objects.get(owner=None) url = '/portal/' self.assertEqual(portal_url(portal=portal), url) self.assertEqual(portal_url(portal=portal, path=''), url) self.assertEqual(portal_url(node=portal.root), url)
def my_portal_url(request): try: return portal_url(portal=request.user.portal) except Portal.DoesNotExist: return reverse('create_user_portal')
def test_portal_url(self): portal = get_portal() root = portal.root child1 = root.children.get(short_name='child1') url = '/~test_user/' self.assertEqual(portal_url(portal=portal), url) self.assertEqual(portal_url(portal=portal, path=''), url) self.assertEqual(portal_url(node=root), url) url = '/~test_user/child1' self.assertEqual(portal_url(portal=portal, path='child1'), url) self.assertEqual(portal_url(node=child1), url) self.assertEqual(portal_url(node=child1, action='show_node'), url) self.assertEqual(portal_url(node=child1, action='edit_node'), url + '?action=edit_node') url = '/~test_user/?action=manage_portal' self.assertEqual(portal_url(portal=portal, action='manage_portal'), url) portal = Portal.objects.get(link_name='default') url = '/p/default/' self.assertEqual(portal_url(portal=portal), url) self.assertEqual(portal_url(portal=portal, path=''), url) self.assertEqual(portal_url(node=portal.root), url)