import sys import pathlib import asyncio import tortoise test_file = pathlib.Path(__file__) project = test_file.parent.parent sys.path.append(str(project)) import server_source as source from test import test 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() first = await source.user_proxy.create("test", "password") test(await first.compare_password("password"), True) await first.result().save() found = await source.user.filter(nick = "test").first() found_proxy = source.user_proxy(found) test(found.nick, "test") test(await found_proxy.compare_password("password"), True) await tortoise.Tortoise.close_connections() asyncio.run(main())