Skip to content

Commit

Permalink
test: achieve/delete task for non existing relation (#988)
Browse files Browse the repository at this point in the history
  • Loading branch information
devkapilbansal authored Mar 28, 2021
1 parent 8f8ae21 commit d52d777
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/tasks/test_dao_complete_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from app import messages
from app.api.dao.task import TaskDAO
from http import HTTPStatus
from tests.tasks.tasks_base_setup import TasksBaseTestCase


Expand Down Expand Up @@ -41,6 +42,21 @@ def test_achieve_not_existent_task(self):

self.assertEqual(expected_response, actual_response)

def test_achieve_task_from_non_existing_relation(self):
task_id = 1

self.assertFalse(self.tasks_list_2.find_task_by_id(task_id).get("is_done"))
expected_response = (
messages.MENTORSHIP_RELATION_DOES_NOT_EXIST,
HTTPStatus.NOT_FOUND,
)

actual_response = TaskDAO.complete_task(
user_id=self.first_user.id, mentorship_relation_id=123123, task_id=task_id
)
self.assertEqual(expected_response, actual_response)
self.assertFalse(self.tasks_list_2.find_task_by_id(task_id).get("is_done"))


if __name__ == "__main__":
unittest.main()
17 changes: 17 additions & 0 deletions tests/tasks/test_dao_delete_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from app import messages
from app.api.dao.task import TaskDAO
from http import HTTPStatus
from tests.tasks.tasks_base_setup import TasksBaseTestCase


Expand All @@ -23,6 +24,22 @@ def test_delete_existent_task(self):
deleted_task = self.tasks_list_1.find_task_by_id(task_id=first_task_id)
self.assertIsNone(deleted_task)

def test_delete_task_from_non_existing_relation(self):
expected_response = (
messages.MENTORSHIP_RELATION_DOES_NOT_EXIST,
HTTPStatus.NOT_FOUND,
)
second_task_id = 2

second_task = self.tasks_list_1.find_task_by_id(task_id=second_task_id)
self.assertIsNotNone(second_task)

actual_response = TaskDAO.delete_task(
user_id=self.first_user.id, mentorship_relation_id=4, task_id=second_task_id
)

self.assertEqual(expected_response, actual_response)

def test_delete_non_existent_task(self):

expected_response = messages.TASK_DOES_NOT_EXIST, HTTPStatus.NOT_FOUND
Expand Down

0 comments on commit d52d777

Please sign in to comment.