100 percent test coverage achieved, patching a critical api bug in api.serializers and .views
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
@@ -24,7 +24,6 @@ class ListDetailAPITest(BaseAPITest):
|
||||
self.assertEqual(len(response.data["items"]), 2)
|
||||
|
||||
class ListItemsAPITest(BaseAPITest):
|
||||
|
||||
def test_can_add_item_to_list(self):
|
||||
list_ = List.objects.create(owner=self.user)
|
||||
|
||||
@@ -37,6 +36,28 @@ class ListItemsAPITest(BaseAPITest):
|
||||
self.assertEqual(Item.objects.count(), 1)
|
||||
self.assertEqual(Item.objects.first().text, "a new item")
|
||||
|
||||
def test_cannot_add_empty_item_to_list(self):
|
||||
list_ = List.objects.create(owner=self.user)
|
||||
|
||||
response = self.client.post(
|
||||
f"/api/lists/{list_.id}/items/",
|
||||
{"text": ""},
|
||||
)
|
||||
|
||||
self.assertEqual(response.status_code, 400)
|
||||
self.assertEqual(Item.objects.count(), 0)
|
||||
|
||||
def test_cannot_add_duplicate_item_to_list(self):
|
||||
list_ = List.objects.create(owner=self.user)
|
||||
Item.objects.create(text="list item", list=list_)
|
||||
duplicate_response = self.client.post(
|
||||
f"/api/lists/{list_.id}/items/",
|
||||
{"text": "list item"},
|
||||
)
|
||||
|
||||
self.assertEqual(duplicate_response.status_code, 400)
|
||||
self.assertEqual(Item.objects.count(), 1)
|
||||
|
||||
class ListsAPITest(BaseAPITest):
|
||||
def test_get_returns_only_users_lists(self):
|
||||
list1 = List.objects.create(owner=self.user)
|
||||
|
||||
Reference in New Issue
Block a user