Skip to content

Commit

Permalink
Merge branch '156'
Browse files Browse the repository at this point in the history
  • Loading branch information
diegomaranhao committed Jun 23, 2020
2 parents acd031c + 8952d05 commit b4d20fb
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 17 deletions.
2 changes: 1 addition & 1 deletion pypro/aperitivos/tests/test_indice.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from model_mommy import mommy

from pypro.aperitivos.models import Video
from pypro.base.django_assertions import assert_contains
from pypro.django_assertions import assert_contains


@pytest.fixture
Expand Down
2 changes: 1 addition & 1 deletion pypro/aperitivos/tests/test_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from model_mommy import mommy

from pypro.aperitivos.models import Video
from pypro.base.django_assertions import assert_contains
from pypro.django_assertions import assert_contains


@pytest.fixture
Expand Down
28 changes: 18 additions & 10 deletions pypro/base/templates/base/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
</button>

<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ml-auto">
<ul class="navbar-nav mr-auto">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Expand All @@ -48,16 +48,24 @@
{% endfor %}
</div>
</li>
<li class="nav-item">
<a class="nav-link js-scroll-trigger" href="#about">About</a>
</li>
<li class="nav-item">
<a class="nav-link js-scroll-trigger" href="#services">Services</a>
</li>
<li class="nav-item">
<a class="nav-link js-scroll-trigger" href="#contact">Contact</a>
</li>
</ul>
{% if user.is_authenticated %}
<ul class="navbar-nav ml-auto">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
{{ user.first_name }}
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<button type="button" class="dropdown-item">Sair</button>

</div>
</li>
</ul>
{% else %}
<a class="btn btn-light" href="{% url 'login' %}">Entrar</a>
{% endif %}

</div>
</div>
</nav>
Expand Down
2 changes: 1 addition & 1 deletion pypro/base/tests/test_home.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
from django.urls import reverse

from pypro.base.django_assertions import assert_contains
from pypro.django_assertions import assert_contains


@pytest.fixture
Expand Down
36 changes: 36 additions & 0 deletions pypro/base/tests/test_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from django.urls import reverse
from model_mommy import mommy

from pypro.django_assertions import assert_contains, assert_not_contains


@pytest.fixture
def resp(client, db):
Expand Down Expand Up @@ -30,3 +32,37 @@ def resp_post(client, usuario):
def test_login_redirect(resp_post):
assert resp_post.status_code == 302
assert resp_post.url == reverse('modulos:indice')


@pytest.fixture
def resp_home(client, db):
return client.get(reverse('base:home'))


def test_botao_entrar_disponivel(resp_home):
assert_contains(resp_home, 'Entrar')


def test_link_entrar_disponivel(resp_home):
assert_contains(resp_home, reverse('login'))


@pytest.fixture
def resp_home_com_usuario_logado(clinet_com_usuario_logado, db):
return clinet_com_usuario_logado.get(reverse('base:home'))


def test_botao_entrar_indisponivel(resp_home_com_usuario_logado):
assert_not_contains(resp_home_com_usuario_logado, 'Entrar')


def test_link_entrar_indisponivel(resp_home_com_usuario_logado):
assert_not_contains(resp_home_com_usuario_logado, reverse('login'))


def test_botao_sair_disponivel(resp_home_com_usuario_logado):
assert_contains(resp_home_com_usuario_logado, 'Sair')


def test_nome_usuario_disponivel(resp_home_com_usuario_logado, usuario_logado):
assert_contains(resp_home_com_usuario_logado, usuario_logado.first_name)
14 changes: 14 additions & 0 deletions pypro/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import pytest
from model_mommy import mommy


@pytest.fixture
def usuario_logado(db, django_user_model):
usuario_modelo = mommy.make(django_user_model, first_name='Fulano')
return usuario_modelo


@pytest.fixture
def clinet_com_usuario_logado(usuario_logado, client):
client.force_login(usuario_logado)
return client
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
_test_case = TestCase()

assert_contains = _test_case.assertContains
assert_not_contains = _test_case.assertNotContains
2 changes: 1 addition & 1 deletion pypro/modulos/test/test_aba_de_modulos.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from django.urls import reverse
from model_mommy import mommy

from pypro.base.django_assertions import assert_contains
from pypro.django_assertions import assert_contains
from pypro.modulos.models import Modulo


Expand Down
2 changes: 1 addition & 1 deletion pypro/modulos/test/test_aula_detalhe.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from django.urls import reverse
from model_mommy import mommy

from pypro.base.django_assertions import assert_contains
from pypro.django_assertions import assert_contains
from pypro.modulos.models import Modulo, Aula


Expand Down
2 changes: 1 addition & 1 deletion pypro/modulos/test/test_modulo_detalhe.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from django.urls import reverse
from model_mommy import mommy

from pypro.base.django_assertions import assert_contains
from pypro.django_assertions import assert_contains
from pypro.modulos.models import Modulo, Aula


Expand Down
2 changes: 1 addition & 1 deletion pypro/modulos/test/test_modulos_indice.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from django.urls import reverse
from model_mommy import mommy

from pypro.base.django_assertions import assert_contains
from pypro.django_assertions import assert_contains
from pypro.modulos.models import Modulo, Aula


Expand Down

0 comments on commit b4d20fb

Please sign in to comment.