Skip to content

Commit

Permalink
Fixing error with district user and cache
Browse files Browse the repository at this point in the history
  • Loading branch information
delcroip committed Nov 8, 2024
1 parent e54270d commit 772b81a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion location/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def cache_location_graph(location_id=None):


def cache_location_graph_if_empty():
if cache.has_key("location_types") is None:
if not cache.has_key("location_types"):
cache_location_graph()


Expand Down
5 changes: 4 additions & 1 deletion location/tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from claim.test_helpers import create_test_claim_admin
from django.core.cache import caches

from location.models import LocationManager
from location.models import LocationManager, UserDistrict
from core.services import (
create_or_update_interactive_user,
create_or_update_core_user,
Expand Down Expand Up @@ -123,6 +123,9 @@ def test_allowed_location(self):
)
cached = caches["location"].get(f"user_locations_{self.test_user._u.id}")
self.assertIsNotNone(cached)
districts = UserDistrict.get_user_districts(self.test_user)
self.assertIsNotNone(cached)


def test_cache_invalidation(self):
LocationManager().is_allowed(self.test_user, [])
Expand Down

0 comments on commit 772b81a

Please sign in to comment.