feat(avatar): add user token accounting
This commit is contained in:
@@ -7,7 +7,6 @@ from unittest.mock import AsyncMock, patch
|
||||
import pytest
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
from sqlalchemy.pool import StaticPool
|
||||
|
||||
from database import Base
|
||||
from models import Avatar, TakeoverCursor, TakeoverMessage, TakeoverReplyTask, User
|
||||
@@ -59,11 +58,10 @@ class FakeBoxIM:
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def service_context():
|
||||
def service_context(tmp_path):
|
||||
engine = create_engine(
|
||||
"sqlite://",
|
||||
f"sqlite:///{tmp_path / 'takeover.db'}",
|
||||
connect_args={"check_same_thread": False},
|
||||
poolclass=StaticPool,
|
||||
)
|
||||
session_factory = sessionmaker(bind=engine, autoflush=False, expire_on_commit=False)
|
||||
Base.metadata.create_all(engine)
|
||||
@@ -156,7 +154,7 @@ async def test_different_contacts_generate_without_blocking_each_other(service_c
|
||||
)
|
||||
both_generating = Barrier(2, timeout=2)
|
||||
|
||||
def resolve(_db, _avatar, prompt, _history):
|
||||
def resolve(_db, _avatar, prompt, _history, **_kwargs):
|
||||
both_generating.wait()
|
||||
return {"answer": f"回复{prompt[-1]}"}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user