Skip to content

Commit

Permalink
Fix middleware tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Wout Feys committed Nov 28, 2024
1 parent a64bf19 commit 87782c1
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions aikido_zen/middleware/init_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_with_context_without_cache():

def test_with_context_with_cache():
set_context(user={"id": "123"})
threadCache = MyThreadCache()
thread_cache = MyThreadCache()

thread_cache.config.blocked_uids = ["123"]
assert get_current_context().executed_middleware == False
Expand All @@ -73,9 +73,9 @@ def test_with_context_with_cache():

def test_cache_comms_with_endpoints():
set_context(user={"id": "456"})
threadCache = MyThreadCache()
threadCache.blocked_uids = ["123"]
threadCache.endpoints = [
thread_cache = MyThreadCache()
thread_cache.config.blocked_uids = ["123"]
thread_cache.config.endpoints = [
{
"method": "POST",
"route": "/login",
Expand All @@ -102,7 +102,7 @@ def test_cache_comms_with_endpoints():
assert should_block_request() == {"block": False}
mock_comms.send_data_to_bg_process.assert_not_called()

threadCache.endpoints.append(
thread_cache.config.endpoints.append(
{
"method": "POST",
"route": "/posts/:id",
Expand All @@ -124,7 +124,7 @@ def test_cache_comms_with_endpoints():
mock_comms.send_data_to_bg_process.assert_not_called()

# Enable ratelimiting
threadCache.endpoints[1]["rateLimiting"]["enabled"] = True
thread_cache.config.endpoints[1]["rateLimiting"]["enabled"] = True

with patch("aikido_zen.background_process.comms.get_comms") as mock_get_comms:
mock_comms = MagicMock()
Expand Down

0 comments on commit 87782c1

Please sign in to comment.