Add test, comments

pull/1395/head
Piero Toffanin 2023-09-16 11:26:24 -04:00
rodzic c6d4c763f0
commit 82f3408b94
3 zmienionych plików z 23 dodań i 1 usunięć

Wyświetl plik

@ -1,6 +1,8 @@
from django.contrib.auth.models import User, Group
from django.test import Client
from rest_framework import status
from guardian.shortcuts import assign_perm
from nodeodm.models import ProcessingNode
from app.models import Project, Task
from app.models import Setting
@ -24,6 +26,11 @@ class TestApp(BootTestCase):
# Add user to test Group
User.objects.get(pk=1).groups.add(my_group)
# Add view permissions
user = User.objects.get(username=self.credentials['username'])
pns = ProcessingNode.objects.all()
for pn in pns:
assign_perm('view_processingnode', user, pn)
def test_user_login(self):
c = Client()
@ -89,6 +96,18 @@ class TestApp(BootTestCase):
self.assertEqual(message.tags, 'warning')
self.assertTrue("offline" in message.message)
# The menu should have 3 processing nodes
res = c.get('/dashboard/', follow=True)
self.assertEqual(res.content.decode("utf-8").count('href="/processingnode/'), 3)
self.assertTemplateUsed(res, 'app/dashboard.html')
# We can change that with a setting
settings.UI_MAX_PROCESSING_NODES = 1
res = c.get('/dashboard/', follow=True)
self.assertEqual(res.content.decode("utf-8").count('href="/processingnode/'), 1)
self.assertTemplateUsed(res, 'app/dashboard.html')
res = c.get('/processingnode/9999/')
self.assertTrue(res.status_code == 404)

Wyświetl plik

@ -109,7 +109,7 @@ def about(request):
def processing_node(request, processing_node_id):
pn = get_object_or_404(ProcessingNode, pk=processing_node_id)
if not pn.update_node_info():
messages.add_message(request, messages.constants.WARNING, '{} seems to be offline.'.format(pn))
messages.add_message(request, messages.constants.WARNING, _('%(node)s seems to be offline.') % {'node': pn})
return render(request, 'app/processing_node.html',
{

Wyświetl plik

@ -391,7 +391,10 @@ CACHES = {
# before it should be considered offline
NODE_OFFLINE_MINUTES = 5
# URL to external auth endpoint
EXTERNAL_AUTH_ENDPOINT = ''
# URL to a page where a user can reset the password
RESET_PASSWORD_LINK = ''
# Number of hours before tasks are automatically deleted