Skip to content

Commit

Permalink
atualização nos testes com a nova lógica de usuário(username)
Browse files Browse the repository at this point in the history
  • Loading branch information
dlpaf committed Jan 7, 2025
1 parent 1b3f1de commit 91431bd
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions back/agenda/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,15 @@ def test_cadastrar_usuario_view(self):
"username": "mariasantos",
"senha": "senha456"
}
response = self.client.post(
reverse('cadastrar_usuario'),
data=json.dumps(data),
content_type='application/json'
)
with open('test_image.jpg', 'rb') as img:
response = self.client.post(
reverse('cadastrar_usuario'),
data={
**data,
"imagem": img
},
format='multipart'
)
self.assertEqual(response.status_code, 201)
self.assertTrue(Usuario.objects.filter(username="mariasantos").exists())

Expand All @@ -48,11 +52,12 @@ def test_cadastrar_usuario_com_username_repetido(self):
}
response = self.client.post(
reverse('cadastrar_usuario'),
data=json.dumps(data),
content_type='application/json'
data=data,
format='multipart'
)
self.assertEqual(response.status_code, 400)
self.assertIn("username", response.json())
self.assertIn("erro", response.json())
self.assertEqual(response.json()["erro"], "Nome de usuário já existe.")

def test_listar_usuarios_view(self):
"""Testa o endpoint de listagem de usuários"""
Expand All @@ -62,7 +67,6 @@ def test_listar_usuarios_view(self):
self.assertEqual(len(usuarios), 1)
self.assertEqual(usuarios[0]['nome'], "João")


class EventoTests(TestCase):
def setUp(self):
"""Configuração inicial para os testes de Evento"""
Expand Down

0 comments on commit 91431bd

Please sign in to comment.