-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Criado a exibição das turmas cadastradas
Close #47
- Loading branch information
1 parent
84ef6d0
commit d642231
Showing
5 changed files
with
49 additions
and
16 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
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,9 @@ | ||
from typing import List | ||
from project.turmas.models import Turma | ||
|
||
|
||
def listar_turmas_ordenadas() -> List[Turma]: | ||
""" | ||
Lista as turmas ordenadas pelo inicio | ||
""" | ||
return list(Turma.objects.order_by('inicio').all()) |
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
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 |
---|---|---|
@@ -1,11 +1,34 @@ | ||
import pytest | ||
from django.urls import reverse | ||
from model_bakery import baker | ||
from project.turmas.models import Turma | ||
from project.django_assertions import assert_contains | ||
|
||
|
||
@pytest.fixture | ||
def resp(client, db): | ||
def turmas(db): | ||
return baker.make(Turma, 2) | ||
|
||
|
||
@pytest.fixture | ||
def resp(client, turmas): | ||
return client.get(reverse('turmas:indice')) | ||
|
||
|
||
def test_status_code(resp): | ||
assert resp.status_code == 200 | ||
|
||
|
||
def test_nomes_turmas(resp, turmas): | ||
for turma in turmas: | ||
assert_contains(resp, turma.nome) | ||
|
||
|
||
def test_inicio_turmas(resp, turmas): | ||
for turma in turmas: | ||
assert_contains(resp, turma.inicio.strftime("%d/%m/%Y")) | ||
|
||
|
||
def test_fim_turmas(resp, turmas): | ||
for turma in turmas: | ||
assert_contains(resp, turma.fim.strftime("%d/%m/%Y")) |
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 |
---|---|---|
@@ -1,5 +1,8 @@ | ||
from django.shortcuts import render | ||
from project.turmas import facade | ||
|
||
|
||
def indice(request): | ||
return render(request, 'turmas/indice.html') | ||
turmas = facade.listar_turmas_ordenadas() | ||
|
||
return render(request, 'turmas/indice.html', {'turmas': turmas}) |