Skip to content

Commit

Permalink
refactor(chat/tests, chat/views): melhora a legibilidade das mensagen…
Browse files Browse the repository at this point in the history
…s de erro e do código
  • Loading branch information
Potatoyz908 committed Feb 10, 2025
1 parent 61bff35 commit 6cb5db5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 3 additions & 3 deletions API/chat/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
from chat.models import ChatRoom, Message
from users.models import Item


'''class ChatRoomViewSetTests(APITestCase):
"""class ChatRoomViewSetTests(APITestCase):
def setUp(self):
self.user1 = User.objects.create_user(username="user1", password="password")
Expand Down Expand Up @@ -39,7 +38,8 @@ def test_create_chat_room_duplicate(self):
response = self.client.post("/api/chat/chatrooms/", data)
assert response.status_code == status.HTTP_400_BAD_REQUEST
assert "Já existe um chat para este item com os mesmos participantes." in response.data'''
assert "Já existe um chat para este item com os mesmos participantes."
in response.data"""


class MessageViewSetTests(APITestCase):
Expand Down
4 changes: 3 additions & 1 deletion API/chat/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ def create(self, request, *args, **kwargs):
).first()

if existing_chat:
raise ValidationError("Já existe um chat para este item com os mesmos participantes.")
raise ValidationError(
"Já existe um chat para este item com os mesmos participantes."
)

# 🔄 Se não existir, cria o chat normalmente
return super().create(request, *args, **kwargs)
Expand Down

0 comments on commit 6cb5db5

Please sign in to comment.