feat: stabilize multi-region runtime sync and worker orchestration
This commit is contained in:
27
domain-api/tests/test_redis_client.py
Normal file
27
domain-api/tests/test_redis_client.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
from app.core.redis_client import get_redis, reset_redis_client_for_tests
|
||||
|
||||
|
||||
class ApiRedisClientTests(unittest.TestCase):
|
||||
def tearDown(self) -> None:
|
||||
reset_redis_client_for_tests()
|
||||
|
||||
@patch("app.core.redis_client.redis.Redis")
|
||||
@patch("app.core.redis_client.redis.BlockingConnectionPool")
|
||||
def test_get_redis_reuses_singleton_client(self, mock_pool, mock_redis) -> None:
|
||||
singleton = object()
|
||||
mock_redis.return_value = singleton
|
||||
|
||||
client_a = get_redis()
|
||||
client_b = get_redis()
|
||||
|
||||
self.assertIs(client_a, singleton)
|
||||
self.assertIs(client_b, singleton)
|
||||
mock_pool.assert_called_once()
|
||||
mock_redis.assert_called_once()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user