diff --git a/idhub/tests/test_tables.py b/idhub/tests/test_tables.py index 7c3ad89..2a6b28b 100644 --- a/idhub/tests/test_tables.py +++ b/idhub/tests/test_tables.py @@ -1,6 +1,9 @@ +import json + from datetime import datetime from unittest.mock import MagicMock +from django.conf import settings from django.test import TestCase from django.urls import reverse from django.core.exceptions import FieldError @@ -15,6 +18,8 @@ class AdminDashboardTableTest(TestCase): self.admin_user = User.objects.create_superuser( email='adminuser@example.org', password='adminpass12') + self.admin_user.accept_gdpr=True + self.admin_user.save() @classmethod def setUpTestData(cls): @@ -118,7 +123,18 @@ class TemplateTableTest(TestCase): ) def format_data_for_json_reader(self, name, description): - return '{"name": "'+name+'", "description": "'+description+'"}' + v = { + "name": [{ + "lang": settings.LANGUAGE_CODE, + "value": name + }], + "description": [{ + "lang": settings.LANGUAGE_CODE, + "value": description + }] + } + return json.dumps(v) + # return '{"name": "'+name+'", "description": "'+description+'"}' def test_order_table_by_name_throws_no_exception(self): try: diff --git a/idhub/tests/test_templates.py b/idhub/tests/test_templates.py index c1b8f3c..d505d11 100644 --- a/idhub/tests/test_templates.py +++ b/idhub/tests/test_templates.py @@ -2,6 +2,7 @@ from django.urls import reverse from django.test import Client, TestCase from idhub_auth.models import User +from django.conf import settings class TemplateTest(TestCase): @@ -10,6 +11,8 @@ class TemplateTest(TestCase): self.admin_user = User.objects.create_superuser( email='adminuser@example.org', password='adminpass12') + self.admin_user.accept_gdpr=True + self.admin_user.save() def test_dashboard_template(self): self.client.login(email='adminuser@example.org', password='adminpass12') diff --git a/idhub/tests/test_views.py b/idhub/tests/test_views.py index fd131c0..b23f9de 100644 --- a/idhub/tests/test_views.py +++ b/idhub/tests/test_views.py @@ -8,11 +8,18 @@ from idhub.admin.views import PeopleListView class AdminDashboardViewTest(TestCase): def setUp(self): - self.user = User.objects.create_user(email='normaluser@example.org', - password='testpass12') + self.user = User.objects.create_user( + email='normaluser@example.org', + password='testpass12', + ) + self.user.accept_gdpr=True + self.user.save() + self.admin_user = User.objects.create_superuser( email='adminuser@example.org', password='adminpass12') + self.admin_user.accept_gdpr=True + self.admin_user.save() def test_view_url_exists_at_desired_location(self): response = self.client.get('/admin/dashboard/', follow=True) @@ -62,14 +69,20 @@ class PeopleListViewTest(TestCase): # Create some user instances for testing self.user = User.objects.create_user(email='normaluser@example.org', password='testpass12') + self.user.accept_gdpr=True + self.user.save() self.admin_user = User.objects.create_superuser( email='adminuser@example.org', password='adminpass12') + self.admin_user.accept_gdpr=True + self.admin_user.save() # Create a request object for the view self.request = self.factory.get(reverse('idhub:admin_people_list')) self.request.user = self.admin_user + self.client.login(email='adminuser@example.org', password='adminpass12') + self.request.session = self.client.session def test_template_used(self): response = PeopleListView.as_view()(self.request)