Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified backend/api/__pycache__/__init__.cpython-313.pyc
Binary file not shown.
Binary file modified backend/api/__pycache__/admin.cpython-313.pyc
Binary file not shown.
Binary file modified backend/api/__pycache__/apps.cpython-313.pyc
Binary file not shown.
Binary file modified backend/api/__pycache__/backend.cpython-313.pyc
Binary file not shown.
Binary file modified backend/api/__pycache__/models.cpython-313.pyc
Binary file not shown.
Binary file modified backend/api/__pycache__/serializers.cpython-313.pyc
Binary file not shown.
Binary file modified backend/api/__pycache__/urls.cpython-313.pyc
Binary file not shown.
Binary file modified backend/api/__pycache__/utils.cpython-313.pyc
Binary file not shown.
Binary file modified backend/api/management/__pycache__/__init__.cpython-313.pyc
Binary file not shown.
Binary file not shown.
24 changes: 24 additions & 0 deletions backend/api/migrations/0025_alter_sign_id_alter_video_id.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 5.2.5 on 2025-10-30 18:42

import uuid
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('api', '0024_alter_sign_id_alter_video_id'),
]

operations = [
migrations.AlterField(
model_name='sign',
name='id',
field=models.UUIDField(default=uuid.UUID('cc38ed65-ae25-498a-9d5f-04bc81c0bb6a'), editable=False, primary_key=True, serialize=False, unique=True),
),
migrations.AlterField(
model_name='video',
name='id',
field=models.UUIDField(default=uuid.UUID('75b5f668-9053-4e99-817a-fe592d8f973f'), editable=False, primary_key=True, serialize=False, unique=True),
),
]
Binary file modified backend/api/migrations/__pycache__/0001_initial.cpython-313.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified backend/api/migrations/__pycache__/__init__.cpython-313.pyc
Binary file not shown.
Binary file modified backend/api/tests/__pycache__/__init__.cpython-313.pyc
Binary file not shown.
Binary file modified backend/api/tests/unit/__pycache__/__init__.cpython-313.pyc
Binary file not shown.
Binary file modified backend/api/tests/unit/__pycache__/test_backend.cpython-313.pyc
Binary file not shown.
Binary file modified backend/api/tests/unit/__pycache__/test_models.cpython-313.pyc
Binary file not shown.
Binary file not shown.
Binary file modified backend/api/tests/unit/__pycache__/test_urls.cpython-313.pyc
Binary file not shown.
Binary file modified backend/api/tests/unit/__pycache__/test_utils.cpython-313.pyc
Binary file not shown.
86 changes: 76 additions & 10 deletions backend/api/tests/unit/test_urls.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,57 @@
from django.test import TestCase, Client
import importlib
from django.contrib.auth import get_user_model

class TestAuthUrls(TestCase):
def setUp(self) -> None:
self.client = Client()
self.email_teste = "login@teste.com"
self.senha_teste = "SenhaForte@123"
self.user = get_user_model().objects.create_user(
email=self.email_teste,
password=self.senha_teste,
first_name="Usuario",
last_name="Login"
)

def test_if_is_running(self) -> None:
self.assertTrue(True)

def test_if_auth_token_route_exists(self) -> None:
response = self.client.post("/api/auth/login")
self.assertEqual(response.status_code, 400)
def test_if_auth_token_route_blocks_get_method(self) -> None:
response = self.client.get("/api/auth/login")
self.assertEqual(response.status_code, 405)

def test_login_sucesso_retorna_tokens(self) -> None:
login_data = {
"email": self.email_teste,
"password": self.senha_teste
}
response = self.client.post("/api/auth/login", data=login_data)

def test_if_auth_token_route_returns_not_found(self) -> None:
response = self.client.get("/api/auth/login/")
self.assertEqual(response.status_code, 404)
self.assertEqual(response.status_code, 200)

def test_if_auth_token_return_200_sucess_in_message(self) -> None:
#response = self.client.get|()
pass
response_data = response.json()
self.assertIn("access", response_data)
self.assertIn("refresh", response_data)
self.assertEqual(response_data["email"], self.email_teste)
self.assertTrue("user_id" in response_data)

def test_login_falha_com_senha_errada(self) -> None:
login_data_errado = {
"email": self.email_teste,
"password": "SENHA_ERRADA"
}
response = self.client.post("/api/auth/login", data=login_data_errado)
self.assertIn(response.status_code, [400, 401])

def test_login_falha_com_usuario_inexistente(self) -> None:
login_data_inexistente = {
"email": "naoexiste@teste.com",
"password": "qualquersenha"
}
response = self.client.post("/api/auth/login", data=login_data_inexistente)
self.assertIn(response.status_code, [400, 401])

class TestUserUrls(TestCase):
def setUp(self) -> None:
self.client = Client()
Expand Down Expand Up @@ -51,4 +84,37 @@ def test_if_single_user_route_exists(self) -> None:
if path.name == "singular_user":
exists = True
break
self.assertTrue(exists)
self.assertTrue(exists)

def test_se_o_cadastro_de_usuario_funciona(self) -> None:
user_data = {
"email": "usuario_novo@teste.com",
"password": "SenhaForte@123",
"first_name": "Tester",
"last_name": "QA"
}
user_count_before = get_user_model().objects.count()
response = self.client.post("/api/users", data=user_data)

self.assertEqual(response.status_code, 201)
user_count_after = get_user_model().objects.count()
self.assertEqual(user_count_after, user_count_before + 1)
response_data = response.json()
self.assertEqual(response_data['user']['email'], user_data['email'])

def test_se_cadastro_falha_com_email_duplicado(self) -> None:
get_user_model().objects.create_user(
email="email.duplicado@teste.com",
password="123",
first_name="Usuario Original"
)
user_data_duplicada = {
"email": "email.duplicado@teste.com",
"password": "OutraSenha@123",
"first_name": "Tentativa de Clone"
}
user_count_before = get_user_model().objects.count()
response = self.client.post("/api/users", data=user_data_duplicada)
self.assertEqual(response.status_code, 400)
user_count_after = get_user_model().objects.count()
self.assertEqual(user_count_after, user_count_before)
49 changes: 49 additions & 0 deletions backend/api/tests/unit/test_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
from django.test import TestCase
from django.core.files.uploadedfile import SimpleUploadedFile
from api.utils import verify_video_file_extension_is_ok

class TestUtilsVideoExtension(TestCase):

def test_com_extensao_valida_deve_retornar_true(self):
"""
Caso de Teste (Caminho Feliz):
Verifica se um arquivo com uma extensão de vídeo válida (.mp4) retorna True.
"""
video_file = SimpleUploadedFile("video_teste.mp4", b"file_content")

resultado = verify_video_file_extension_is_ok(video_file)

self.assertTrue(resultado)

def test_com_extensao_invalida_deve_retornar_false(self):
"""
Caso de Teste (Caminho Triste):
Verifica se um arquivo de texto (.txt) retorna False.
"""
text_file = SimpleUploadedFile("documento.txt", b"file_content")

resultado = verify_video_file_extension_is_ok(text_file)

self.assertFalse(resultado)

def test_com_extensao_maiuscula_deve_retornar_true(self):
"""
Caso de Teste (Borda):
Verifica se a função ignora o case (maiúsculas/minúsculas) da extensão.
"""
video_file_upper = SimpleUploadedFile("video_upper.MP4", b"file_content")

resultado = verify_video_file_extension_is_ok(video_file_upper)

self.assertTrue(resultado)

def test_sem_extensao_deve_retornar_false(self):
"""
Caso de Teste (Borda):
Verifica o comportamento com um arquivo sem extensão.
"""
file_no_ext = SimpleUploadedFile("arquivo_sem_extensao", b"file_content")

resultado = verify_video_file_extension_is_ok(file_no_ext)

self.assertFalse(resultado)
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified backend/api/views/__pycache__/__init__.cpython-313.pyc
Binary file not shown.
Binary file modified backend/api/views/__pycache__/auth_views.cpython-313.pyc
Binary file not shown.
Binary file modified backend/api/views/__pycache__/sign_views.cpython-313.pyc
Binary file not shown.
Binary file modified backend/api/views/__pycache__/user_views.cpython-313.pyc
Binary file not shown.
Binary file modified backend/api/views/__pycache__/video_views.cpython-313.pyc
Binary file not shown.
Binary file modified backend/backend/__pycache__/__init__.cpython-313.pyc
Binary file not shown.
Binary file modified backend/backend/__pycache__/settings.cpython-313.pyc
Binary file not shown.
Binary file modified backend/backend/__pycache__/urls.cpython-313.pyc
Binary file not shown.
Binary file modified backend/backend/__pycache__/wsgi.cpython-313.pyc
Binary file not shown.
Binary file modified backend/db.sqlite3
Binary file not shown.