Skip to content

Commit

Permalink
Patch redis module in tests
Browse files Browse the repository at this point in the history
Make sure the tests can be run even if redis isn't installed.
  • Loading branch information
CendioOssman committed Feb 8, 2024
1 parent 0427f63 commit bccf1dd
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/test_token_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

""" Unit tests for Token plugins"""

import sys
import unittest
from unittest.mock import patch, mock_open, MagicMock
from jwcrypto import jwt, jwk
Expand Down Expand Up @@ -178,6 +179,14 @@ def test_asymmetric_jwe_token_plugin(self):
self.assertEqual(result[1], "remote_port")

class TokenRedisTestCase(unittest.TestCase):
def setUp(self):
try:
import redis
except ImportError:
patcher = patch.dict(sys.modules, {'redis': MagicMock()})
patcher.start()
self.addCleanup(patcher.stop)

@patch('redis.Redis')
def test_empty(self, mock_redis):
plugin = TokenRedis('127.0.0.1:1234')
Expand Down

0 comments on commit bccf1dd

Please sign in to comment.