Skip to content
Merged
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
4 changes: 2 additions & 2 deletions pythonpro/modules/templates/modules/module_detail.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends 'core/base.html' %}
{% load static %}

{% load permission_tags %}
{% block title %}{{ module.title }}{% endblock %}
{% block description %}{{ module.description }}{% endblock %}

Expand All @@ -15,7 +15,7 @@ <h1 class="mt-4 mb-3">{{ module.title }}</h1>
<li>{{ module.objective }}</li>
</ul>
</dd>
{% if module.slug == 'python-birds' %}
{% if module.slug == 'python-birds' and user|has_role:'client,member' %}
<dt>Duração: 4 semanas</dt>
<dd>
<ul>
Expand Down
21 changes: 16 additions & 5 deletions pythonpro/modules/tests/test_module_detail_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django.urls import reverse
from model_mommy import mommy

from pythonpro.django_assertions import dj_assert_contains, dj_assert_template_used
from pythonpro.django_assertions import dj_assert_contains, dj_assert_not_contains, dj_assert_template_used
from pythonpro.modules import facade
from pythonpro.modules.models import Chapter, Module, Section

Expand Down Expand Up @@ -41,6 +41,21 @@ def test_lead_content(content, client_with_lead, modules):
dj_assert_contains(resp, content)


def test_lead_has_no_automation_button(client_with_lead, modules, python_birds):
resp = generate_resp('python-birds', client_with_lead)
dj_assert_not_contains(resp, reverse('modules:enrol', kwargs={'slug': python_birds.slug}))


def test_client_has_no_automation_button(client_with_client, modules, python_birds):
resp = generate_resp('python-birds', client_with_client)
dj_assert_contains(resp, reverse('modules:enrol', kwargs={'slug': python_birds.slug}))


def test_member_has_no_automation_button(client_with_member, modules, python_birds):
resp = generate_resp('python-birds', client_with_member)
dj_assert_contains(resp, reverse('modules:enrol', kwargs={'slug': python_birds.slug}))


@pytest.mark.parametrize(
'content',
[
Expand Down Expand Up @@ -124,10 +139,6 @@ def test_chapter_urls(resp_with_chapters, chapters):
dj_assert_contains(resp_with_chapters, chapter.get_absolute_url())


def test_python_birds_enrol_link(resp_with_sections, python_birds):
dj_assert_contains(resp_with_sections, reverse('modules:enrol', kwargs={'slug': python_birds.slug}))


def test_enrol_user_tags(python_birds, client_with_lead, mocker, logged_user):
tag_as = mocker.patch('pythonpro.modules.modules_views.tag_as')
resp = client_with_lead.get(reverse('modules:enrol', kwargs={'slug': python_birds.slug}), secure=True)
Expand Down