Skip to content

Commit

Permalink
fix: atualizando branch com a main
Browse files Browse the repository at this point in the history
  • Loading branch information
m4rllon committed Aug 12, 2024
2 parents 165fab9 + d23f0e9 commit 7ec72e4
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 3 deletions.
51 changes: 49 additions & 2 deletions backend/server/app/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
from django.db.models import Sum, F
from django.db.models.functions import Cast
from django.db.models import FloatField
from unittest.mock import patch
from datetime import datetime
from django.test import TestCase

class Tests(APITestCase):

Expand Down Expand Up @@ -181,7 +183,7 @@ def test_licitacoes_valores_anuais_vazio(self):
response = self.client.get(reverse('valores-anuais-list'))
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.data, [])

# TESTE DO ENDPOINT LICITACAO_MAIOR_VALOR
def test_licitacao_maior_valor(self):
# Fazer uma requisição GET para o endpoint
Expand Down Expand Up @@ -209,4 +211,49 @@ def test_licitacao_maior_valor_sem_licitacoes(self):
self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)

# Verificar se a mensagem de erro está correta
self.assertEqual(response.data, {'detail': 'Nenhuma licitação encontrada.'})
self.assertEqual(response.data, {'detail': 'Nenhuma licitação encontrada.'})

# TESTE DO ENDPOINT SUBSCRIBE_EMAIL
@patch('app.views.requests.post')
def test_subscribe_email_success(self, mock_post):
mock_post.return_value.status_code = 200

url = reverse('subscribe_email')
data = {'email_address': 'test@example.com'}
headers = {'HTTP_ORIGIN': 'https://fastidious-daffodil-724e94.netlify.app'}

response = self.client.post(url, data, **headers)
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.data, "Subscription successful!")

@patch('app.views.requests.post')
def test_subscribe_email_no_email(self, mock_post):
# Simula uma resposta 400 para o mock
mock_post.return_value.status_code = 400

# Define a URL para o teste
url = reverse('subscribe_email')
data = {} # Envia dados vazios para simular a falta de um email
headers = {'HTTP_ORIGIN': 'https://fastidious-daffodil-724e94.netlify.app'}

# Faz uma requisição POST
response = self.client.post(url, data, **headers)

# Verifica se o status da resposta é 400 (Bad Request)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)

# Verifica se a mensagem de erro está correta
self.assertEqual(response.data['detail'], "Email is required.")

@patch('app.views.requests.post')
def test_subscribe_email_unauthorized_origin(self, mock_post):
mock_post.return_value.status_code = 403

url = reverse('subscribe_email')
data = {'email_address': 'test@example.com'}
headers = {'HTTP_ORIGIN': 'https://unauthorized-origin.com'}

response = self.client.post(url, data, **headers)

self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
self.assertEqual(response.data['detail'], "Unauthorized origin.")
1 change: 1 addition & 0 deletions frontend/src/components/header/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ const Header = () => {
Dashboard
</a>
</li>
<a></a>
</ul>
<div>
<div className={styles.campoPesquisa}>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/header/style.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
text-decoration: none;
font-family: 'IBM Plex Sans', sans-serif;
font-weight: bold;
font-size: 16px;
font-size: 15px;
color: var(--brancoTexto);
}

Expand Down
2 changes: 2 additions & 0 deletions frontend/src/pages/about-us/card-member/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ export default function CardMember({ nome, descricao, github, id }) {
alt="Foto do membro"
/>
)}
<div className={styles.githubLinkContainer}>
<a data-testid="campoLink" href={github} target="_blank">
<FaGithub /> Github
</a>
</div>
</div>
</li>
);
}

0 comments on commit 7ec72e4

Please sign in to comment.