Skip to content
This repository has been archived by the owner on Aug 5, 2024. It is now read-only.

Commit

Permalink
fix: Create more data for the test tables
Browse files Browse the repository at this point in the history
  • Loading branch information
rsavoye committed Mar 8, 2024
1 parent 112ae4f commit 33fa0fa
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 19 deletions.
6 changes: 3 additions & 3 deletions tests/test_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,23 @@ async def create_messages():
# log.debug(f--- create_message() unimplemented!)
await messages.deleteRecords([1, 2, 3])
await messages.resetSequence()
msg = MessagesTable(id = 197862, message="Hi has just been validated",
msg = MessagesTable(id = 1, message = "Hi has just been validated",
from_user_id = 7775678, to_user_id = 6643593,
date = '2018-06-04T04:49:02.614348',
read = False,message_type=4,
project_id = 3213, task_id = 777,
)
result = await messages.insertRecords([msg])

msg = MessagesTable(id=272032,message="Hi has just been validated",
msg = MessagesTable(id=2, message = "Hi has just been validated",
from_user_id = 7775590, to_user_id = 8405478,
date = '2018-07-19T03:17:42.122209',
read = False, message_type = 4,
project_id = 4231, task_id = 90,
)
result = await messages.insertRecords([msg])

msg = MessagesTable(id=89136,message="Hi has just been validated",
msg = MessagesTable(id = 3, message = "Hi has just been validated",
from_user_id = 5484336, to_user_id = 3043750,
date = '2018-02-07T13:32:47.56986',
read = False, message_type = 4,
Expand Down
8 changes: 4 additions & 4 deletions tests/test_orgs.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,17 @@ async def create_organisations():
await organizations.resetSequence()

# returns True or False
ot = OrganizationsTable(id = 1, name='test org', slug="slug",
org = OrganizationsTable(id = 1, name='test org', slug="slug",
subscription_tier=1,
type=1)
# type=Organizationtype.FREE)
result = await organizations.create(ot)
result = await organizations.insertRecords([org])

ot = OrganizationsTable(id = 2, name='Other', slug="slug",
org = OrganizationsTable(id = 2, name='Other', slug="slug",
subscription_tier=2,
type=2)
# type=Organizationtype.FREE)
result = await organizations.create(ot)
result = await organizations.insertRecords([org])

manager_ids = [1, 2, 3]
organization_id = 1
Expand Down
8 changes: 3 additions & 5 deletions tests/test_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,19 @@ async def create_projects(api):
created = '2021-12-15 09:58:02.672236', organisation_id = 1,
task_creation_mode = 'GRID', status = 'DRAFT', featured = "false",
mapping_level = 'BEGINNER', priority_areas = [1, 2, 3])
# returns True or False
result = await api.create(pt)
result = await projects.insertRecords([pt])

pt = ProjectsTable(id=2, name="World!", author_id = 1, geometry = geom, centroid = center,
created = '2022-12-15 09:58:02.672236', featured = "true",
task_creation_mode = 'CREATE_ROADS', status = 'PUBLISHED',
mapping_level = 'ADVANCED', priority_areas = [1],
organisation_id = 1)
# returns True or False
result = await api.create(pt)
result = await projects.insertRecords([pt])

role = Teamroles(Teamroles.TEAM_MAPPER)
teams = {"team_id": 1, "role": role}
project_id = 1
result = await api.updateColumns({"teams": teams}, {"id": project_id})
result = await projects.updateColumns({"teams": teams}, {"id": project_id})

# These tests are for basic table management
async def delete_project():
Expand Down
41 changes: 36 additions & 5 deletions tests/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,52 @@ async def create_tasks():
project_task_name = "testing, 1,2,3",
is_square = False,
task_status = Taskstatus.READY))
task_id = 1
project_id = 1
history = list()
history.append({"action": Taskaction.RELEASED_FOR_MAPPING,
"action_text": "validated task",
"action_date": "2024-01-25 10:50:56.140958",
"user_id": user_id})
await tasks.updateHistory(history, task_id, project_id)

task_id = 1
history = list()
history.append({"action": Taskaction.LOCKED_FOR_MAPPING,
"action_text": "locked for mapping",
"action_date": "2024-01-23 10:50:56.140958",
"user_id": user_id})

history.append({"action": Taskaction.LOCKED_FOR_VALIDATION,
"action_text": "marked mapped",
"action_date": "2024-01-24 10:50:56.140958",
"user_id": user_id})

history.append({"action": Taskaction.VALIDATED,
"action_text": "marked mapped",
"action_date": "2024-01-25 10:50:56.140958",
"user_id": user_id})
await tasks.appendHistory(history, task_id, project_id)
tl.append(TasksTable(id = 2, project_id = 1,
project_task_name = "testing, 1,2,3",
is_square = True,
task_status = Taskstatus.READY))

result = await tasks.insertRecords(tl)

history.append({"action": Taskaction.RELEASED_FOR_MAPPING,
"action_text": "validated task",
"action_date": "2024-01-25 10:50:56.140958",
"user_id": user_id})
await tasks.updateHistory(history, task_id, project_id)

task_id = 1
project_id = 1
history = list()
history.append({"action": Taskaction.RELEASED_FOR_MAPPING,
"action_text": "validated task",
"action_date": "2024-01-25 10:50:56.140958",
"user_id": user_id})

await tasks.updateHistory(history, task_id, project_id)

task_id = 1
Expand All @@ -92,11 +123,11 @@ async def create_tasks():
await tasks.appendHistory(history, task_id, project_id)

async def get_task():
# task_id: int, project_id: int) -> Task:
log.debug(f"--- get_task() unimplemented!")
task_id = 1
result = await tasks.getByID(task_id)
# result = await tasks.getByID(task_id)
# print(result)
# task_id: int, project_id: int) -> Task:

async def _is_task_undoable():
"""Determines if the current task status can be undone by the logged in user"""
Expand All @@ -106,7 +137,7 @@ 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
task_id = 1
project_id = 3
status = Taskstatus(Taskstatus.TASK_LOCKED_FOR_MAPPING)
result = await tasks.changeStatus(user_id, task_id, project_id, status)
Expand All @@ -116,7 +147,7 @@ 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
task_id = 1
project_id = 3
status = Taskstatus(Taskstatus.TASK_LOCKED_FOR_MAPPING)
result = await tasks.changeStatus(user_id, task_id, project_id, status)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_teams.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ async def create_teams():
join_method = 1, team_members = {"members":
[{"active": "false", "user_id": 1, "function": "MEMBER"},
{"active": "true", "user_id": 2, "function": "MANAGER"}]})
result = await teams.create(team)
result = await teams.insertRecords([team])

team = TeamsTable(id = 2, organisation_id = 56, name = "Not Enough Practice",
description = "Hello World!", visibility = "PUBLIC",
join_method = 1, team_members = {"members":
[{"active": "false", "user_id": 3, "function": "MEMBER"},
{"active": "true", "user_id": 4, "function": "MEMBER"}]})
result = await teams.create(team)
result = await teams.insertRecords([team])

async def get_team_by_id():
log.debug(f"get_team_by_id() unimplemented!")
Expand Down

0 comments on commit 33fa0fa

Please sign in to comment.