add KEY in cache in tests

This commit is contained in:
Cayo Puigdefabregas 2024-02-22 18:50:53 +01:00
parent 2f0c344a57
commit f7ac9a0a3a
2 changed files with 8 additions and 0 deletions

View File

@ -6,6 +6,7 @@ from unittest.mock import MagicMock
from django.conf import settings from django.conf import settings
from django.test import TestCase from django.test import TestCase
from django.urls import reverse from django.urls import reverse
from django.core.cache import cache
from django.core.exceptions import FieldError from django.core.exceptions import FieldError
from idhub_auth.models import User from idhub_auth.models import User
@ -15,6 +16,7 @@ from idhub.models import Event, Membership, Rol, UserRol, Service, Schemas
class AdminDashboardTableTest(TestCase): class AdminDashboardTableTest(TestCase):
def setUp(self): def setUp(self):
cache.set("KEY_DIDS", '1234', None)
self.admin_user = User.objects.create_superuser( self.admin_user = User.objects.create_superuser(
email='adminuser@example.org', email='adminuser@example.org',
password='adminpass12') password='adminpass12')
@ -75,6 +77,7 @@ class AdminDashboardTableTest(TestCase):
class UserTableTest(TestCase): class UserTableTest(TestCase):
def setUp(self): def setUp(self):
cache.set("KEY_DIDS", '1234', None)
self.user1 = User.objects.create(email="user1@example.com") self.user1 = User.objects.create(email="user1@example.com")
self.user2 = User.objects.create(email="user2@example.com") self.user2 = User.objects.create(email="user2@example.com")
Membership.objects.create(user=self.user1, Membership.objects.create(user=self.user1,
@ -106,6 +109,7 @@ class UserTableTest(TestCase):
class TemplateTableTest(TestCase): class TemplateTableTest(TestCase):
def setUp(self): def setUp(self):
cache.set("KEY_DIDS", '1234', None)
self.table = TemplateTable(Schemas.objects.all()) self.table = TemplateTable(Schemas.objects.all())
self.create_schemas(amount=3) self.create_schemas(amount=3)

View File

@ -1,4 +1,5 @@
from django.test import TestCase, RequestFactory from django.test import TestCase, RequestFactory
from django.core.cache import cache
from django.urls import reverse from django.urls import reverse
from idhub_auth.models import User from idhub_auth.models import User
@ -9,6 +10,7 @@ from idhub.admin.views import PeopleListView
class AdminDashboardViewTest(TestCase): class AdminDashboardViewTest(TestCase):
def setUp(self): def setUp(self):
cache.set("KEY_DIDS", '1234', None)
self.user = User.objects.create_user( self.user = User.objects.create_user(
email='normaluser@example.org', email='normaluser@example.org',
password='testpass12', password='testpass12',
@ -99,6 +101,7 @@ class AdminDashboardViewTest(TestCase):
class PeopleListViewTest(TestCase): class PeopleListViewTest(TestCase):
def setUp(self): def setUp(self):
cache.set("KEY_DIDS", '1234', None)
# Set up a RequestFactory to create mock requests # Set up a RequestFactory to create mock requests
self.factory = RequestFactory() self.factory = RequestFactory()
@ -144,6 +147,7 @@ class PeopleListViewTest(TestCase):
class UserDashboardViewTests(TestCase): class UserDashboardViewTests(TestCase):
def setUp(self): def setUp(self):
cache.set("KEY_DIDS", '1234', None)
# Create test users # Create test users
self.admin_user = User.objects.create_superuser('admin@example.org', 'password') self.admin_user = User.objects.create_superuser('admin@example.org', 'password')
self.admin_user.accept_gdpr=True self.admin_user.accept_gdpr=True