diff --git a/tests/test_orgs.py b/tests/test_orgs.py index eb536a2..74e6a62 100755 --- a/tests/test_orgs.py +++ b/tests/test_orgs.py @@ -27,8 +27,9 @@ # from tm_admin.organizations.organizations_proto import OrganizationsMessage #from tm_admin.yamlfile import YamlFile from tm_admin.organizations.organizations import OrganizationsDB +from tm_admin.organizations.organizations_class import OrganizationsTable from tm_admin.organizations.api import OrganizationsAPI -from tm_admin.types_tm import Organizationtype, Mappinglevel +from tm_admin.types_tm import Organizationtype from datetime import datetime import asyncio from codetiming import Timer @@ -42,29 +43,41 @@ # FIXME: For now these tests assume you have a local postgres installed. One has the TM # database, the other for tm_admin. -organization = OrganizationsAPI() +organizations = OrganizationsAPI() + +async def create_organisation(): + # new_organisation_dto: NewOrganisationDTO) -> int: + log.debug(f"create_organisation() unimplemented!") + # returns True or False + ot = OrganizationsTable(name='test org', slug="slug", + subscription_tier=1, + type=1) + # type=Organizationtype.FREE) + result = await organizations.create(ot) + # FIXME: This is supposed to return the id, and does for other tables, + # but for some reason we get no result, but it appears to work + # assert result async def get_organisation_by_id(): log.debug(f"--- get_organisation_by_id() ---") # organisation_id: int) -> Organisation: id = 1 - # all = user.getByID(id) - # result = await organization.getByID(id) - # assert len(result) > 0 + result = await organizations.getByID(id) + assert len(result) > 0 async def get_organisation_by_name(): # organisation_name: str) -> Organisation: log.debug(f"--- get_organisation_by_name() ---") name= 'Other' - # result = await organization.getByName(name) - # assert len(result) > 0 + result = await organizations.getByName(name) + assert len(result) > 0 async def get_organisation_name_by_id(): # organisation_id: int) -> str: log.debug(f"--- get_organisation_name_by_id() ---") - id = 1 - # result = await organization.getByID(id) - # assert len(result) > 0 and result[0][0]['name'] == 'Other' + org_id = 1 + result = await organizations.getColumns(["name"], {"id": org_id}) + assert len(result) > 0 async def get_organisations(): # manager_user_id: int): @@ -79,10 +92,6 @@ async def delete_organisation(): #result = await organization.deleteByID(id) #assert len(result) > 0 -async def create_organisation(): - # new_organisation_dto: NewOrganisationDTO) -> int: - log.debug(f"create_organisation() unimplemented!") - async def update_organisation(): # organisation_dto: UpdateOrganisationDTO) -> Organisation: log.debug(f"update_organisation() unimplemented!") @@ -164,7 +173,7 @@ async def main(): stream=sys.stdout, ) - await organization.connect(args.uri) + await organizations.initialize(args.uri) await get_organisation_by_id() await get_organisation_by_name() diff --git a/tests/test_stats.py b/tests/test_stats.py old mode 100644 new mode 100755 diff --git a/tests/test_tasks.py b/tests/test_tasks.py index 545d8cf..a5136bd 100755 --- a/tests/test_tasks.py +++ b/tests/test_tasks.py @@ -28,7 +28,7 @@ #from tm_admin.yamlfile import YamlFile from tm_admin.users.users import UsersDB from tm_admin.projects.projects import ProjectsDB -from tm_admin.types_tm import Userrole, Mappinglevel +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.api import TasksAPI @@ -41,7 +41,7 @@ import tm_admin as tma rootdir = tma.__path__[0] -task = TasksAPI() +tasks = TasksAPI() # FIXME: For now these tests assume you have a local postgres installed. One has the TM # database, the other for tm_admin. @@ -49,7 +49,8 @@ async def get_task(): log.debug(f"--- get_task() unimplemented!") task_id = 1 - result = await task.getByID(task_id) + result = await tasks.getByID(task_id) + print(result) # task_id: int, project_id: int) -> Task: async def _is_task_undoable(): @@ -59,15 +60,31 @@ async def _is_task_undoable(): async def lock_task_for_mapping(): log.debug(f"--- lock_task_for_mapping() unimplemented!") + user_id = 1 + task_id = 2 + project_id = 3 + status = Taskstatus(Taskstatus.TASK_LOCKED_FOR_MAPPING) + result = await tasks.changeStatus(user_id, task_id, project_id, status) # lock_task_dto: LockTaskDTO) -> TaskDTO: async def unlock_task_after_mapping(): """Unlocks the task and sets the task history appropriately""" log.debug(f"--- unlock_task_after_mapping() unimplemented!") + user_id = 1 + task_id = 2 + project_id = 3 + status = Taskstatus(Taskstatus.TASK_LOCKED_FOR_MAPPING) + result = await tasks.changeStatus(user_id, task_id, project_id, status) # mapped_task: MappedTaskDTO) -> TaskDTO: async def stop_mapping_task(): # stop_task: StopMappingTaskDTO) -> TaskDTO: + log.debug(f"--- unlock_task_after_mapping() unimplemented!") + user_id = 1 + task_id = 2 + project_id = 3 + status = Taskstatus(Taskstatus.TASK_LOCKED_FOR_MAPPING) + result = await tasks.changeStatus(user_id, task_id, project_id, status) log.debug(f"--- stop_mapping_task() unimplemented!") """Unlocks the task and revert the task status to the last one""" @@ -95,11 +112,13 @@ async def undo_mapping(): async def map_all_tasks(): log.debug(f"--- map_all_tasks() unimplemented!") + result = await tasks.markAllMapped() # project_id: int, user_id: int): """Marks all tasks on a project as mapped""" async def reset_all_badimagery(): log.debug(f"--- reset_all_badimagery() unimplemented!") + result = await tasks.resetBadImagery() # project_id: int, user_id: int): """Marks all bad imagery tasks ready for mapping""" @@ -112,9 +131,9 @@ async def extend_task_lock_time(): log.debug(f"--- extend_task_lock_time() unimplemented!") #extend_dto: ExtendLockTimeDTO): -async def get_task_as_dto(): - log.debug(f"--- get_task_as_dto( unimplemented!") - # task_id: int, +# async def get_task_as_dto(): +# log.debug(f"--- get_task_as_dto( unimplemented!") +# # task_id: int, # FMTM API tests async def get_task_count_in_project(): @@ -189,11 +208,11 @@ async def main(): # user = UsersDB(args.uri) # task = TasksDB(args.uri) - await task.connect(args.uri) + await tasks.connect(args.uri) # project = ProjectsDB(args.uri) await get_task() - await get_task_as_dto() + # await get_task_as_dto() await _is_task_undoable() await lock_task_for_mapping() await unlock_task_after_mapping() diff --git a/tests/test_teams.py b/tests/test_teams.py index a408928..c89cc05 100755 --- a/tests/test_teams.py +++ b/tests/test_teams.py @@ -87,13 +87,13 @@ async def create_team(): log.debug(f"create_team() unimplemented!") team = Team_membersTable() # FIXME: add data! - results = await teams.create(team) + # results = await teams.create(team) async def update_team(): log.debug(f"update_team() unimplemented!") team = Team_membersTable() # FIXME: add data! - results = await teams.update(team) + # results = await teams.update(team) async def delete_team(): log.debug(f"delete_team() unimplemented!") @@ -228,7 +228,7 @@ async def main(): stream=sys.stdout, ) - await teams.connect(args.uri) + await teams.initialize(args.uri) await request_to_join_team() await add_user_to_team()