Skip to content

Commit

Permalink
Re-add hard coded locmem test
Browse files Browse the repository at this point in the history
This should be changed in the future, though
  • Loading branch information
rolandgeider committed Jan 11, 2025
1 parent 23e026c commit 3d98589
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions wger/core/tests/api_base_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

# Django
from django.contrib.auth.models import User
from django.core.cache import cache
from django.core.cache.backends import locmem

# Third Party
from rest_framework import status
Expand Down Expand Up @@ -174,21 +174,26 @@ def test_get_overview(self):
def test_get_overview_is_cached(self):
"""
Test accessing the overview view of a resource is cached
TODO: remove the hard coded 'wger-cache' here. This only works for the locmem cache
used in tests.
"""
if self.resource is None:
return

# Ensure the wger cache is empty.

self.assertFalse(cache.keys('*'))
cache_length = len(locmem._caches['wger-cache'])
self.assertEqual(cache_length, 0)

self.test_get_overview()

# If the overview is cached. Then ensure the cache isn't empty.
if self.overview_cached:
self.assertTrue(cache.keys('*'))
cache_length = len(locmem._caches['wger-cache'])
self.assertNotEqual(cache_length, 0)
else:
self.assertFalse(cache.keys('*'))
cache_length = len(locmem._caches['wger-cache'])
self.assertEqual(cache_length, 0)

def test_special_endpoints(self):
"""
Expand Down

0 comments on commit 3d98589

Please sign in to comment.