Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gromdimon committed Apr 10, 2024
1 parent 33cc92a commit 5e7b11d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
{% for link in dropdown_links %}
<li class="nav-item sodar-navbar-alt-item {% if link.active %}active{% endif %}">
<a class="nav-link {% if link.name == 'sign-out' %}text-danger{% endif %}
{% if link.name == 'sign-in' %}text-white{% endif %}"
href="{{ link.url }}"
id="sodar-navbar-nav-link-{{ link.name }}">
{% if link.name == 'sign-in' %}text-white{% endif %}"
href="{{ link.url }}"
id="sodar-navbar-nav-link-{{ link.name }}">
<i class="iconify" data-icon="{{ link.icon }}"></i> {{ link.label }}
</a>
{% endfor %}
Expand Down
20 changes: 16 additions & 4 deletions projectroles/tests/test_templatetags.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,12 +726,11 @@ def test_get_sidebar_links_timeline_view(self):
else:
self.assertEqual(app['active'], False)

def test_get_get_user_links(self):
"""Test get_user_links() on the homepage"""
def test_get_get_user_links_home(self):
"""Test get_user_links() on the home view"""
url = reverse('home')
req_factory = RequestFactory()
with self.login(self.user):
request = req_factory.get(url)
request = self.req_factory.get(url)
request.resolver_match = resolve(url)
request.user = self.user
self.assertEqual(
Expand Down Expand Up @@ -781,3 +780,16 @@ def test_get_get_user_links(self):
},
],
)

def test_get_user_links_userprofile(self):
"""Test get_user_links() on the user profile view"""
url = reverse('userprofile:detail')
with self.login(self.user):
request = self.req_factory.get(url)
request.resolver_match = resolve(url)
request.user = self.user
for app in tags.get_user_links(request):
if app['name'] == 'userprofile':
self.assertEqual(app['active'], True)
else:
self.assertEqual(app['active'], False)
3 changes: 1 addition & 2 deletions projectroles/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from django.urls import reverse
from django.utils import timezone

from projectroles.constants import get_sodar_constants
from projectroles.plugins import get_active_plugins
from projectroles.models import SODAR_CONSTANTS

Expand Down Expand Up @@ -303,7 +302,7 @@ def get_project_app_links(self, request, project=None):


class UserDropdownContent:
"""Class to generate user dropdown content"""
"""Class for generating application links for the dropdown"""

def get_user_links(self, request):
"""Return user links for the user dropdown"""
Expand Down

0 comments on commit 5e7b11d

Please sign in to comment.