Further gql improvements & added test data #181
Some checks failed
Test before pr merge / test-lint (pull_request) Failing after 5s

This commit is contained in:
2025-09-27 21:57:33 +02:00
parent 2e98159d4e
commit af7945fe92
27 changed files with 305 additions and 88 deletions

View File

@@ -0,0 +1,31 @@
from faker import Faker
from cpl.database.abc import DataSeederABC
from cpl.query import Enumerable
from model.post import Post
from model.post_dao import PostDao
fake = Faker()
class TestDataSeeder(DataSeederABC):
def __init__(self, posts: PostDao):
DataSeederABC.__init__(self)
self._posts = posts
async def seed(self):
if await self._posts.count() == 0:
await self._seed_posts()
async def _seed_posts(self):
posts = Enumerable.range(0, 100).select(
lambda x: Post(
id=0,
title=fake.sentence(nb_words=6),
content=fake.paragraph(nb_sentences=6),
)
).to_list()
await self._posts.create_many(posts, skip_editor=True)