fix: update settings for asyncio testing

This commit is contained in:
2025-02-21 17:08:56 +01:00
committed by wakonig_k
parent 7569bc920a
commit ce04dac5be
4 changed files with 26 additions and 26 deletions

View File

@ -1,3 +1,4 @@
import asyncio
import json
import os
from unittest import mock
@ -14,6 +15,11 @@ from bec_atlas.main import AtlasApp
from bec_atlas.router.redis_router import BECAsyncRedisManager
class TestRedis(fakeredis.FakeAsyncRedis):
async def execute_command(self, *args, **options):
return await asyncio.shield(super().execute_command(*args, **options))
def import_mongodb_data(mongo_client: pymongo.MongoClient):
"""
Import the test data into the mongodb container. The data is stored in the
@ -86,9 +92,7 @@ def backend(redis_server):
return fakeredis.FakeStrictRedis(server=redis_server)
mongo_client = mongomock.MongoClient("localhost", 27027)
fake_async_redis = fakeredis.FakeAsyncRedis(
server=redis_server, username="ingestor", password="ingestor"
)
fake_async_redis = TestRedis(server=redis_server, username="ingestor", password="ingestor")
fake_async_redis.connection_pool.connection_kwargs["username"] = "ingestor"
fake_async_redis.connection_pool.connection_kwargs["password"] = "ingestor"