Show certificates for all verified modes
This commit is contained in:
54
common/djangoapps/student/tests/test_certificates.py
Normal file
54
common/djangoapps/student/tests/test_certificates.py
Normal file
@@ -0,0 +1,54 @@
|
||||
"""Tests for display of certificates on the student dashboard. """
|
||||
|
||||
import unittest
|
||||
import ddt
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.urlresolvers import reverse
|
||||
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
|
||||
from xmodule.modulestore.tests.factories import CourseFactory
|
||||
from student.tests.factories import UserFactory, CourseEnrollmentFactory
|
||||
from certificates.tests.factories import GeneratedCertificateFactory # pylint: disable=import-error
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
|
||||
class CertificateDisplayTest(ModuleStoreTestCase):
|
||||
"""Tests display of certificates on the student dashboard. """
|
||||
|
||||
USERNAME = "test_user"
|
||||
PASSWORD = "password"
|
||||
DOWNLOAD_URL = "http://www.example.com/certificate.pdf"
|
||||
|
||||
def setUp(self):
|
||||
super(CertificateDisplayTest, self).setUp()
|
||||
self.user = UserFactory.create(username=self.USERNAME, password=self.PASSWORD)
|
||||
result = self.client.login(username=self.USERNAME, password=self.PASSWORD)
|
||||
self.assertTrue(result, msg="Could not log in")
|
||||
|
||||
self.course = CourseFactory()
|
||||
self.course.certificates_display_behavior = "early_with_info"
|
||||
self.update_course(self.course, self.user.username)
|
||||
|
||||
@ddt.data('verified', 'professional')
|
||||
def test_display_verified_certificate(self, enrollment_mode):
|
||||
self._create_certificate(enrollment_mode)
|
||||
self._check_can_download_certificate()
|
||||
|
||||
def _create_certificate(self, enrollment_mode):
|
||||
"""Simulate that the user has a generated certificate. """
|
||||
CourseEnrollmentFactory.create(user=self.user, course_id=self.course.id, mode=enrollment_mode)
|
||||
GeneratedCertificateFactory(
|
||||
user=self.user,
|
||||
course_id=self.course.id,
|
||||
mode=enrollment_mode,
|
||||
download_url=self.DOWNLOAD_URL,
|
||||
status="downloadable",
|
||||
grade=0.98,
|
||||
)
|
||||
|
||||
def _check_can_download_certificate(self):
|
||||
response = self.client.get(reverse('dashboard'))
|
||||
self.assertContains(response, u'Download Your ID Verified')
|
||||
self.assertContains(response, self.DOWNLOAD_URL)
|
||||
@@ -1,6 +1,9 @@
|
||||
<%page args="cert_status, course, enrollment" />
|
||||
|
||||
<%! from django.utils.translation import ugettext as _ %>
|
||||
<%!
|
||||
from django.utils.translation import ugettext as _
|
||||
from course_modes.models import CourseMode
|
||||
%>
|
||||
<%namespace name='static' file='../static_content.html'/>
|
||||
|
||||
<%
|
||||
@@ -61,7 +64,7 @@ else:
|
||||
<a class="btn" href="${cert_status['download_url']}"
|
||||
title="${_('This link will open/download a PDF document')}">
|
||||
${_("Download Your {cert_name_short} (PDF)").format(cert_name_short=cert_name_short)}</a></li>
|
||||
% elif cert_status['show_download_url'] and enrollment.mode == 'verified':
|
||||
% elif cert_status['show_download_url'] and enrollment.mode in CourseMode.VERIFIED_MODES:
|
||||
<li class="action">
|
||||
<a class="btn" href="${cert_status['download_url']}"
|
||||
title="${_('This link will open/download a PDF document of your verified {cert_name_long}.').format(cert_name_long=cert_name_long)}">
|
||||
|
||||
Reference in New Issue
Block a user