import sys import pathlib test_file = pathlib.Path(__file__) project = test_file.parent.parent sys.path.append(str(project)) import server_source as source from test import test import asyncio import tortoise async def main(): modules = { source.model.Meta.app: [ "server_source" ] } await tortoise.Tortoise.init( db_url = "sqlite://:memory:", modules = modules ) await tortoise.Tortoise.generate_schemas() books = source.category.get_proxy().create("books").result() await books.save() test(str(books), "books") test(len(await source.category_manager.all()), 1) loaded_books = await source.category_manager.add("books") test(len(await source.category_manager.all()), 1) games = await source.category_manager.add("games") test(len(await source.category_manager.all()), 2) await source.category_manager.clean("books") test(len(await source.category_manager.all()), 1) await tortoise.Tortoise.close_connections() asyncio.run(main())