Skip to content

Commit

Permalink
test: more tests for the Management Service
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielborgesdm committed May 19, 2024
1 parent ba16206 commit a1061d4
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions backend/tests/services/test_management_service.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from datetime import date
from werkzeug.exceptions import BadRequest

from backend.tests.conftest import BaseTestCase
from backend.tests.mocks.author_mock import author_create_mock, author_create_without_name_mock
from backend.tests.mocks.mock_utils import get_mock_with_custom_args
Expand All @@ -17,18 +19,21 @@

class TestCreateBook(BaseTestCase):
def test_should_create_book_and_its_author(self):
self.assertEqual(len(management_service.get_authors()), 0)

book = management_service.create_book(book_mock)

self.assertEqual(len(management_service.get_authors()), 1)

self.assertEqual(book.get("title"), book_mock.get("title"))
self.assertEqual(book.get("pages"), book_mock.get("pages"))

def test_should_create_book_and_find_a_created_author(self):
def test_should_throw_when_author_is_inexistent(self):
self.assertEqual(len(management_service.get_authors()), 0)

with self.assertRaises(BadRequest):
book_with_inexistent_author_mock = get_book_with_authors([{"existentAuthorId": 1}])
management_service.create_book(book_with_inexistent_author_mock)

def test_should_create_book_and_find_a_created_author(self):
author = management_service.create_author(author_mock)

self.assertIsNotNone(author.get("id"))
Expand Down

0 comments on commit a1061d4

Please sign in to comment.