test: migrate load balancing account ORM model to real entity (#40644)

This commit is contained in:
Asuka Minato
2026-08-14 05:34:00 +00:00
committed by GitHub
parent 78dfce3b63
commit 9f048cd89b
@@ -5,7 +5,6 @@ from __future__ import annotations
import builtins
import importlib
import sys
from types import SimpleNamespace
from unittest.mock import ANY, MagicMock
import pytest
@@ -19,7 +18,7 @@ from graphon.model_runtime.errors.validate import CredentialsValidateFailedError
if not hasattr(builtins, "MethodView"):
builtins.MethodView = MethodView # type: ignore[attr-defined]
from models.account import TenantAccountRole
from models.account import Account, TenantAccountRole
@pytest.fixture
@@ -57,12 +56,15 @@ def load_balancing_module(monkeypatch: pytest.MonkeyPatch):
return module
def _mock_user(role: TenantAccountRole) -> SimpleNamespace:
return SimpleNamespace(current_role=role)
def _account(role: TenantAccountRole) -> Account:
account = Account(name="Owner", email="owner@example.com")
account.id = "account-1"
account.role = role
return account
def _prepare_context(module, monkeypatch: pytest.MonkeyPatch, role=TenantAccountRole.OWNER):
user = _mock_user(role)
user = _account(role)
from controllers.console import wraps
monkeypatch.setattr(wraps, "current_account_with_tenant", lambda: (user, "tenant-123"))