test: use tmp_path for _user_db_path tests; remove duplicate comment
Patch _user_db_path tests to monkeypatch CLOUD_DATA_ROOT onto a tmp_path so they never touch /devl or any real filesystem path. Remove duplicate X-Real-IP comment block in cloud_session.get_session.
This commit is contained in:
parent
9985d12156
commit
ed6813713e
2 changed files with 9 additions and 9 deletions
|
|
@ -208,8 +208,6 @@ def get_session(request: Request) -> CloudUser:
|
|||
if not CLOUD_MODE:
|
||||
return CloudUser(user_id="local", tier="local", db=_LOCAL_KIWI_DB, has_byok=has_byok)
|
||||
|
||||
# Prefer X-Real-IP (set by nginx from the actual client address) over the
|
||||
# TCP peer address (which is nginx's container IP when behind the proxy).
|
||||
# Prefer X-Real-IP (set by nginx from the actual client address) over the
|
||||
# TCP peer address (which is nginx's container IP when behind the proxy).
|
||||
client_ip = (
|
||||
|
|
|
|||
|
|
@ -6,10 +6,10 @@ import pytest
|
|||
|
||||
os.environ.setdefault("CLOUD_MODE", "false")
|
||||
|
||||
import app.cloud_session as cs
|
||||
from app.cloud_session import (
|
||||
CloudUser,
|
||||
_user_db_path,
|
||||
CLOUD_DATA_ROOT,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -28,11 +28,13 @@ def test_clouduser_household_defaults_none():
|
|||
assert u.is_household_owner is False
|
||||
|
||||
|
||||
def test_user_db_path_personal():
|
||||
path = _user_db_path("abc123", household_id=None)
|
||||
assert path == CLOUD_DATA_ROOT / "abc123" / "kiwi.db"
|
||||
def test_user_db_path_personal(tmp_path, monkeypatch):
|
||||
monkeypatch.setattr(cs, "CLOUD_DATA_ROOT", tmp_path)
|
||||
result = cs._user_db_path("abc123")
|
||||
assert result == tmp_path / "abc123" / "kiwi.db"
|
||||
|
||||
|
||||
def test_user_db_path_household():
|
||||
path = _user_db_path("abc123", household_id="hh-xyz")
|
||||
assert path == CLOUD_DATA_ROOT / "household_hh-xyz" / "kiwi.db"
|
||||
def test_user_db_path_household(tmp_path, monkeypatch):
|
||||
monkeypatch.setattr(cs, "CLOUD_DATA_ROOT", tmp_path)
|
||||
result = cs._user_db_path("abc123", household_id="hh-xyz")
|
||||
assert result == tmp_path / "household_hh-xyz" / "kiwi.db"
|
||||
|
|
|
|||
Loading…
Reference in a new issue