Skip to content

Commit

Permalink
🧪 test: adicionando os testes do endpoint LICITACAO_POR_ID
Browse files Browse the repository at this point in the history
  • Loading branch information
thaleseuflauzino committed Aug 12, 2024
1 parent 040b4a8 commit 999970e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions backend/server/app/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,21 @@ def test_listar_licitacoes_ordenar_por_valor(self):
self.assertEqual(response.status_code, status.HTTP_200_OK)
valores = [licitacao['valores'][0] for licitacao in response.data['results'] if licitacao['valores']]
self.assertEqual(valores, sorted(valores))

# TESTE DO ENDPOINT LICITACAO_POR_ID
def test_licitacao_por_id_valido(self):
licitacao = Licitacao.objects.first()
url = reverse('licitacao_por_id', args=[licitacao.id])
response = self.client.get(url)

self.assertEqual(response.status_code, status.HTTP_200_OK)

serializer = LicitacaoSerializer(licitacao)
self.assertEqual(response.data, serializer.data)

def test_licitacao_por_id_invalido(self):
url = reverse('licitacao_por_id', args=[999])
response = self.client.get(url)

self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
self.assertEqual(response.data, {'detail': 'Licitacao não encontrada'})

0 comments on commit 999970e

Please sign in to comment.