Skip to content

Commit

Permalink
Update task and label fixtures (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
samarpan1738 committed Dec 11, 2024
1 parent c7da5b9 commit e0661f7
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 86 deletions.
22 changes: 22 additions & 0 deletions todo/tests/fixtures/label.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from bson import ObjectId
from todo.models.label import LabelModel


label_db_data = [
{
"_id": ObjectId("67478036eac9d93db7f59c35"),
"name": "Label 1",
"color": "#fa1e4e",
"createdAt": "2024-11-08T10:14:35",
"createdBy": "qMbT6M2GB65W7UHgJS4g",
},
{
"_id": ObjectId("67588c1ac2195684a575840c"),
"name": "Label 2",
"color": "#ea1e4e",
"createdAt": "2024-11-08T10:14:35",
"createdBy": "qMbT6M2GB65W7UHgJS4g",
},
]

label_models = [LabelModel(**data) for data in label_db_data]
7 changes: 0 additions & 7 deletions todo/tests/fixtures/label_model.py

This file was deleted.

78 changes: 78 additions & 0 deletions todo/tests/fixtures/task.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
from todo.constants.task import TaskPriority
from todo.models.task import TaskModel
from todo.constants.task import TaskStatus
from todo.dto.task_dto import TaskDTO
from bson import ObjectId

tasks_db_data = [
{
"id": ObjectId("672f7c5b775ee9f4471ff1dd"),
"displayId": "#1",
"title": "Task 1",
"description": "Test task 1",
"priority": TaskPriority.HIGH.value,
"status": TaskStatus.TODO.value,
"assignee": "qMbT6M2GB65W7UHgJS4g",
"isAcknowledged": True,
"labels": [ObjectId("67588c1ac2195684a575840c"), ObjectId("67478036eac9d93db7f59c35")],
"createdAt": "2024-11-08T10:14:35",
"updatedAt": "2024-11-08T15:14:35",
"createdBy": "qMbT6M2GB65W7UHgJS4g",
"updatedBy": "qMbT6M2GB65W7UHgJS4g",
},
{
"id": ObjectId("674c726ca89aab38040cb964"),
"displayId": "#2",
"title": "Task 2",
"description": "Test task 2",
"priority": TaskPriority.MEDIUM.value,
"status": TaskStatus.IN_PROGRESS.value,
"assignee": "qMbT6M2GB65W7UHgJS4g",
"isAcknowledged": False,
"labels": [ObjectId("67588c1ac2195684a575840c"), ObjectId("67478036eac9d93db7f59c35")],
"createdAt": "2024-11-08T10:14:35",
"updatedAt": "2024-11-08T15:14:35",
"createdBy": "qMbT6M2GB65W7UHgJS4g",
"updatedBy": "qMbT6M2GB65W7UHgJS4g",
},
]

tasks_models = [TaskModel(**data) for data in tasks_db_data]


task_dtos = [
TaskDTO(
id="672f7c5b775ee9f4471ff1dd",
displayId="#1",
title="created rest api",
priority=1,
status="TODO",
assignee={"id": "qMbT6M2GB65W7UHgJS4g", "name": "SYSTEM"},
isAcknowledged=False,
labels=[{"name": "Beginner Friendly", "color": "#fa1e4e"}],
isDeleted=False,
startedAt="2024-11-09T15:14:35.724000",
dueAt="2024-11-09T15:14:35.724000",
createdAt="2024-11-09T15:14:35.724000",
updatedAt="2024-10-18T15:55:14.802000Z",
createdBy={"id": "xQ1CkCncM8Novk252oAj", "name": "SYSTEM"},
updatedBy={"id": "Kn5N4Z3mdvpkv0HpqUCt", "name": "SYSTEM"},
),
TaskDTO(
id="674c726ca89aab38040cb964",
displayId="#1",
title="task 2",
priority=1,
status="TODO",
assignee={"id": "qMbT6M2GB65W7UHgJS4g", "name": "SYSTEM"},
isAcknowledged=True,
labels=[{"name": "Beginner Friendly", "color": "#fa1e4e"}],
isDeleted=False,
startedAt="2024-11-09T15:14:35.724000",
dueAt="2024-11-09T15:14:35.724000",
createdAt="2024-11-09T15:14:35.724000",
updatedAt="2024-10-18T15:55:14.802000Z",
createdBy={"id": "xQ1CkCncM8Novk252oAj", "name": "SYSTEM"},
updatedBy={"id": "Kn5N4Z3mdvpkv0HpqUCt", "name": "SYSTEM"},
),
]
38 changes: 0 additions & 38 deletions todo/tests/fixtures/task_dto.py

This file was deleted.

38 changes: 0 additions & 38 deletions todo/tests/fixtures/task_model.py

This file was deleted.

4 changes: 2 additions & 2 deletions todo/tests/unit/services/test_task_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from todo.dto.user_dto import UserDTO
from todo.services.task_service import TaskService
from todo.dto.task_dto import TaskDTO
from todo.tests.fixtures.task_model import tasks_models
from todo.tests.fixtures.label_model import label_models
from todo.tests.fixtures.task import tasks_models
from todo.tests.fixtures.label import label_models


class TaskServiceTests(TestCase):
Expand Down
2 changes: 1 addition & 1 deletion todo/tests/unit/views/test_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from rest_framework.response import Response
from todo.constants.task import DEFAULT_PAGE_LIMIT
from todo.dto.responses.get_tasks_response import GetTasksResponse
from todo.tests.fixtures.task_dto import task_dtos
from todo.tests.fixtures.task import task_dtos


class TaskViewTests(APISimpleTestCase):
Expand Down

0 comments on commit e0661f7

Please sign in to comment.