From f7ac9a0a3ad248502b422d657d7eba5951e2e3a9 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Thu, 22 Feb 2024 18:50:53 +0100 Subject: [PATCH] add KEY in cache in tests --- idhub/tests/test_tables.py | 4 ++++ idhub/tests/test_views.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/idhub/tests/test_tables.py b/idhub/tests/test_tables.py index 2a6b28b..3dfe181 100644 --- a/idhub/tests/test_tables.py +++ b/idhub/tests/test_tables.py @@ -6,6 +6,7 @@ from unittest.mock import MagicMock from django.conf import settings from django.test import TestCase from django.urls import reverse +from django.core.cache import cache from django.core.exceptions import FieldError from idhub_auth.models import User @@ -15,6 +16,7 @@ from idhub.models import Event, Membership, Rol, UserRol, Service, Schemas class AdminDashboardTableTest(TestCase): def setUp(self): + cache.set("KEY_DIDS", '1234', None) self.admin_user = User.objects.create_superuser( email='adminuser@example.org', password='adminpass12') @@ -75,6 +77,7 @@ class AdminDashboardTableTest(TestCase): class UserTableTest(TestCase): def setUp(self): + cache.set("KEY_DIDS", '1234', None) self.user1 = User.objects.create(email="user1@example.com") self.user2 = User.objects.create(email="user2@example.com") Membership.objects.create(user=self.user1, @@ -106,6 +109,7 @@ class UserTableTest(TestCase): class TemplateTableTest(TestCase): def setUp(self): + cache.set("KEY_DIDS", '1234', None) self.table = TemplateTable(Schemas.objects.all()) self.create_schemas(amount=3) diff --git a/idhub/tests/test_views.py b/idhub/tests/test_views.py index a6c66f7..10e5b24 100644 --- a/idhub/tests/test_views.py +++ b/idhub/tests/test_views.py @@ -1,4 +1,5 @@ from django.test import TestCase, RequestFactory +from django.core.cache import cache from django.urls import reverse from idhub_auth.models import User @@ -9,6 +10,7 @@ from idhub.admin.views import PeopleListView class AdminDashboardViewTest(TestCase): def setUp(self): + cache.set("KEY_DIDS", '1234', None) self.user = User.objects.create_user( email='normaluser@example.org', password='testpass12', @@ -99,6 +101,7 @@ class AdminDashboardViewTest(TestCase): class PeopleListViewTest(TestCase): def setUp(self): + cache.set("KEY_DIDS", '1234', None) # Set up a RequestFactory to create mock requests self.factory = RequestFactory() @@ -144,6 +147,7 @@ class PeopleListViewTest(TestCase): class UserDashboardViewTests(TestCase): def setUp(self): + cache.set("KEY_DIDS", '1234', None) # Create test users self.admin_user = User.objects.create_superuser('admin@example.org', 'password') self.admin_user.accept_gdpr=True