-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adicionando testes para views de turmas
- Loading branch information
1 parent
429247f
commit 77238b2
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
from django.test import TestCase, Client | ||
from rest_framework.test import APIClient | ||
from django.urls import reverse | ||
from turmas.views import Turma | ||
from turmas.serializers import TurmaSerializer | ||
import json | ||
|
||
class TurmaViewsCasosdeTeste(TestCase): | ||
cliente = APIClient() | ||
|
||
def criar_turma(self): | ||
turma = Turma.objects.create( | ||
nome_turma = "Felicidade", | ||
ano_turma = 2019, | ||
periodo_turma = 2 | ||
) | ||
return turma | ||
|
||
def testa_listar_turmas_GET(self): | ||
resposta = self.cliente.get(reverse('lista_turmas')) | ||
self.assertEquals(resposta.status_code, 200) | ||
|
||
def testa_criar_turmas_POST(self): | ||
resposta = self.cliente.post(reverse('cria_turmas'), { | ||
'nome_turma':'Felicidade', | ||
'ano_turma':'2019', | ||
'periodo_turma':'2' | ||
}, format='json') | ||
self.assertEquals(resposta.status_code, 200) | ||
|
||
def testa_get_turma_GET(self): | ||
turma = self.criar_turma() | ||
id = turma.pk | ||
resposta = self.client.get(reverse('mostra_turma', args = [id])) | ||
self.assertEquals(resposta.status_code, 200) | ||
|
||
def testa_editar_turma_PUT(self): | ||
turma = self.criar_turma() | ||
id = turma.pk | ||
resposta = self.cliente.put(reverse('edita_turma', args = [id])) | ||
self.assertEquals(resposta.status_code, 200) | ||
|
||
def testa_deletar_turmas_DELETE(self): | ||
turma = self.criar_turma() | ||
id = turma.pk | ||
resposta = self.cliente.delete(reverse('deleta_turma', args = [id])) | ||
self.assertEquals(resposta.status_code, 200) | ||
|
||
|