From 8caf943a5d77346bf4e114aea1a7f862761a2372 Mon Sep 17 00:00:00 2001 From: Rob Savoye Date: Mon, 4 Mar 2024 14:18:59 -0700 Subject: [PATCH] fix: Add test for creating a table class and inserting it into the table --- tests/test_messages.py | 12 ++++++++++++ tests/test_tasks.py | 19 +++++++++++++++---- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/tests/test_messages.py b/tests/test_messages.py index e171b1b..b8de43d 100755 --- a/tests/test_messages.py +++ b/tests/test_messages.py @@ -48,6 +48,17 @@ # user = UsersDB() messages = MessagesAPI() +async def create_message(): + project_id = 1 + # log.debug(f"--- create_message() unimplemented!") + msg = MessagesTable(message="Hello World!", + subject="test", + project_id=project_id, + from_user_id=0, + to_user_id=1 + ) + result = await messages.create(msg) + async def get_all_messages(): log.debug(f"--- get_all_messages() unimplemented!") # user_id: int, @@ -211,6 +222,7 @@ async def main(): # await user.connect(args.uri) await messages.initialize(args.uri) + await create_message() await send_welcome_message() await send_message_after_validation() diff --git a/tests/test_tasks.py b/tests/test_tasks.py index a5136bd..7b4d0ee 100755 --- a/tests/test_tasks.py +++ b/tests/test_tasks.py @@ -26,11 +26,11 @@ from sys import argv # from tm_admin.users.users_proto import UsersMessage #from tm_admin.yamlfile import YamlFile -from tm_admin.users.users import UsersDB -from tm_admin.projects.projects import ProjectsDB +# from tm_admin.users.users import UsersDB +# from tm_admin.projects.projects import ProjectsDB from tm_admin.types_tm import Userrole, Mappinglevel, Taskstatus from datetime import datetime -from tm_admin.users.users_class import UsersTable +from tm_admin.tasks.tasks_class import TasksTable from tm_admin.tasks.api import TasksAPI import asyncio from codetiming import Timer @@ -46,6 +46,16 @@ # FIXME: For now these tests assume you have a local postgres installed. One has the TM # database, the other for tm_admin. +async def create_task(): + project_id = 1 + log.debug(f"--- create_task() unimplemented!") + task = TasksTable(project_id=1, + project_task_name="testing, 1,2,3", + is_square="false", + task_status=Taskstatus.READY, + ) + result = await tasks.create(task) + async def get_task(): log.debug(f"--- get_task() unimplemented!") task_id = 1 @@ -208,7 +218,8 @@ async def main(): # user = UsersDB(args.uri) # task = TasksDB(args.uri) - await tasks.connect(args.uri) + await tasks.initialize(args.uri) + await create_task() # project = ProjectsDB(args.uri) await get_task()