feat: change QuoteStorerSvc to use the new quote repo instead of the legacy db object

This commit is contained in:
cătălin 2025-02-13 10:20:03 +01:00
commit 3058ca112d
No known key found for this signature in database
10 changed files with 75 additions and 47 deletions

View file

@ -3,9 +3,11 @@ from pathlib import Path
import pytest
from caribou.migrate import Database as CaribouDatabase
from caribou.migrate import load_migrations
from polyfactory.factories.pydantic_factory import ModelFactory
from polyfactory.pytest_plugin import register_fixture
from src.huesoporro.infra.db import Database
from src.huesoporro.models import ChatbotSettings, User
from src.huesoporro.models import ChatbotSettings, Quote, User
from src.huesoporro.settings import Settings
from src.huesoporro.svc.backoff_service import BackoffService
from src.huesoporro.svc.is_mod import IsModSvc
@ -79,3 +81,12 @@ async def backoff_svc(backoff_callable, async_backoff_callable):
backoff_svc.add_callable(backoff_callable, 3)
backoff_svc.add_callable(async_backoff_callable, 3)
return backoff_svc
@register_fixture()
class QuoteFactory(ModelFactory[Quote]): ...
@pytest.fixture
def quote(quote_factory):
return quote_factory.build()

View file

@ -68,3 +68,8 @@ async def test_get_random_quote(quote_repo: QuoteRepo):
assert quote
assert quote.author.user == "author"
assert quote.channel.user == "channel"
async def test_create_quote(quote, quote_repo):
new_quote = await quote_repo.create(quote)
assert new_quote == quote