aboutsummaryrefslogtreecommitdiff
path: root/test_utils/managers
diff options
context:
space:
mode:
authorMax Nanis2026-09-01 12:29:10 -0700
committerMax Nanis2026-09-01 12:29:10 -0700
commit6469e7e55a53cfe18bd015b3c455ecbbb550cbb9 (patch)
tree15ed92293881207dc03641b6c24b24d0576185c5 /test_utils/managers
parent89ed44f466dc9a93d6f85931fb6eea0e9cbd27f6 (diff)
downloadgeneralresearch-6469e7e55a53cfe18bd015b3c455ecbbb550cbb9.tar.gz
generalresearch-6469e7e55a53cfe18bd015b3c455ecbbb550cbb9.zip
WIP Business tests, fixture cleanup(s)
Diffstat (limited to 'test_utils/managers')
-rw-r--r--test_utils/managers/gr/conftest.py28
-rw-r--r--test_utils/managers/thl/conftest.py37
2 files changed, 33 insertions, 32 deletions
diff --git a/test_utils/managers/gr/conftest.py b/test_utils/managers/gr/conftest.py
index 5392c69..a7fa9e9 100644
--- a/test_utils/managers/gr/conftest.py
+++ b/test_utils/managers/gr/conftest.py
@@ -9,7 +9,6 @@ import pytest
import redis
import redis.asyncio as redis_async
from pydantic import PostgresDsn
-from redis import Redis
from generalresearch.managers.gr.business import (
BusinessAddressManager,
@@ -31,33 +30,6 @@ def gr_redis_config_db() -> str:
@pytest.fixture(scope="session")
-def gr_redis(settings: GRLBaseSettings) -> Redis:
- assert "unittest" in str(settings.testing_redis) or "127.0.0.1" in str(
- settings.testing_redis
- )
- return Redis.from_url(
- url=str(settings.gr_redis),
- decode_responses=True,
- socket_timeout=settings.redis_timeout,
- socket_connect_timeout=settings.redis_timeout,
- )
-
-
-@pytest.fixture
-def gr_redis_async(settings: GRLBaseSettings) -> redis_async.Redis:
- assert "unittest" in str(settings.testing_redis) or "127.0.0.1" in str(
- settings.testing_redis
- )
-
- return redis_async.Redis.from_url(
- str(settings.testing_redis),
- decode_responses=True,
- socket_timeout=0.20,
- socket_connect_timeout=0.20,
- )
-
-
-@pytest.fixture(scope="session")
def gr_redis_config(
settings: GRLBaseSettings, gr_redis_config_db: str
) -> Generator[RedisConfig]:
diff --git a/test_utils/managers/thl/conftest.py b/test_utils/managers/thl/conftest.py
index af3fd23..391b74c 100644
--- a/test_utils/managers/thl/conftest.py
+++ b/test_utils/managers/thl/conftest.py
@@ -1,9 +1,12 @@
from __future__ import annotations
-from collections.abc import Callable
+import subprocess
+from collections.abc import Callable, Generator
+from random import randint
from typing import TYPE_CHECKING
import pytest
+import redis
from pydantic import PostgresDsn
from generalresearch.managers.base import Permission
@@ -59,14 +62,40 @@ def thl_web_rw(thl_web_rr: PostgresConfig) -> PostgresConfig:
@pytest.fixture(scope="session")
-def thl_redis_config(settings: GRLBaseSettings) -> RedisConfig:
- return RedisConfig(
- dsn=settings.thl_redis,
+def thl_redis_config_db() -> str:
+ return str(randint(99, 1_023))
+
+
+@pytest.fixture(scope="session")
+def thl_redis_config(
+ settings: GRLBaseSettings, thl_redis_config_db: str
+) -> Generator[RedisConfig]:
+ assert "unittest" in str(settings.testing_redis) or "127.0.0.1" in str(
+ settings.testing_redis
+ )
+
+ uri = f"redis://{settings.testing_redis}/{thl_redis_config_db}"
+
+ res = subprocess.run(
+ ["redis-cli", "-u", uri, "SET", "jenkins_lock", "1", "NX", "EX", "3600"],
+ check=True,
+ text=True,
+ capture_output=True,
+ )
+
+ if res.stdout.strip() != "OK":
+ raise ValueError("Redis already locked... aborting.")
+
+ yield RedisConfig(
+ dsn=uri,
decode_responses=True,
socket_timeout=settings.redis_timeout,
socket_connect_timeout=settings.redis_timeout,
)
+ r = redis.from_url(uri)
+ r.flushdb()
+
@pytest.fixture(scope="session")
def payout_event_manager(