예제 #1
0
    def test_evidence_event_sent(self):
        self._add_course_certificates(count=1, signatory_count=2)

        cert_url = get_certificate_url(
            user_id=self.user.id,
            course_id=self.course_id
        )
        test_url = '{}?evidence_visit=1'.format(cert_url)
        self.recreate_tracker()
        assertion = BadgeAssertionFactory.create(
            user=self.user, course_id=self.course_id,
        )
        response = self.client.get(test_url)
        self.assertEqual(response.status_code, 200)
        assert_event_matches(
            {
                'name': 'edx.badge.assertion.evidence_visited',
                'data': {
                    'course_id': 'testorg/run1/refundable_course',
                    'assertion_id': assertion.id,
                    'assertion_json_url': 'http://www.example.com/assertion.json',
                    'assertion_image_url': 'http://www.example.com/image.png',
                    'user_id': self.user.id,
                    'issuer': 'http://www.example.com/issuer.json',
                    'enrollment_mode': 'honor',
                },
            },
            self.get_event()
        )
예제 #2
0
 def test_clear_badge(self, xqueue):
     """
     Given that I have a user with a badge
     If I run regeneration for a user
     Then certificate generation will be requested
     And the badge will be deleted
     """
     key = self.course.location.course_key
     BadgeAssertionFactory(user=self.user, course_id=key, data={})
     self._create_cert(key, self.user, CertificateStatuses.downloadable)
     self.assertTrue(
         BadgeAssertion.objects.filter(user=self.user, course_id=key))
     self._run_command(username=self.user.email,
                       course=unicode(key),
                       noop=False,
                       insecure=False,
                       template_file=None,
                       grade_value=None)
     xqueue.return_value.regen_cert.assert_called_with(self.user,
                                                       key,
                                                       course=self.course,
                                                       forced_grade=None,
                                                       template_file=None,
                                                       generate_pdf=True)
     self.assertFalse(
         BadgeAssertion.objects.filter(user=self.user, course_id=key))
예제 #3
0
 def setUp(self):
     super(TrackShareRedirectTest, self).setUp('certificates.urls')
     self.client = Client()
     self.course = CourseFactory.create(
         org='testorg', number='run1', display_name='trackable course'
     )
     self.assertion = BadgeAssertionFactory(
         user=self.user, course_id=self.course.id, data={
             'image': 'http://www.example.com/image.png',
             'json': {'id': 'http://www.example.com/assertion.json'},
             'issuer': 'http://www.example.com/issuer.json'
         },
     )
예제 #4
0
 def setUp(self):
     super(TrackShareRedirectTest, self).setUp()
     self.client = Client()
     self.course = CourseFactory.create(
         org='testorg', number='run1', display_name='trackable course'
     )
     self.assertion = BadgeAssertionFactory(
         user=self.user, course_id=self.course.id, data={
             'image': 'http://www.example.com/image.png',
             'json': {'id': 'http://www.example.com/assertion.json'},
             'issuer': 'http://www.example.com/issuer.json',
         },
     )
     # Enabling the feature flag isn't enough to change the URLs-- they're already loaded by this point.
     self.old_patterns = urls.urlpatterns
     urls.urlpatterns += (urls.BADGE_SHARE_TRACKER_URL,)
예제 #5
0
    def test_rendering_maximum_data(self):
        """
        Tests at least one data item from different context update methods to
        make sure every context update method is invoked while rendering certificate template.
        """
        long_org_name = 'Long org name'
        short_org_name = 'short_org_name'
        test_organization_data = {
            'name': long_org_name,
            'short_name': short_org_name,
            'description': 'Test Organization Description',
            'active': True,
            'logo': '/logo_test1.png'
        }
        test_org = organizations_api.add_organization(organization_data=test_organization_data)
        organizations_api.add_organization_course(organization_data=test_org, course_id=unicode(self.course.id))
        self._add_course_certificates(count=1, signatory_count=1, is_active=True)
        BadgeAssertionFactory.create(
            user=self.user, course_id=self.course_id,
        )
        self.course.cert_html_view_overrides = {
            "logo_src": "/static/certificates/images/course_override_logo.png"
        }

        self.course.save()
        self.store.update_item(self.course, self.user.id)

        test_url = get_certificate_url(
            user_id=self.user.id,
            course_id=unicode(self.course.id)
        )
        response = self.client.get(test_url, HTTP_HOST=settings.MICROSITE_TEST_HOSTNAME)

        # Test an item from basic info
        self.assertIn(
            'Terms of Service & Honor Code',
            response.content
        )
        self.assertIn(
            'Certificate ID Number',
            response.content
        )
        # Test an item from html cert configuration
        self.assertIn(
            '<a class="logo" href="http://test_microsite.localhost">',
            response.content
        )
        # Test an item from course info
        self.assertIn(
            'course_title_0',
            response.content
        )
        # Test an item from user info
        self.assertIn(
            "{fullname}, you earned a certificate!".format(fullname=self.user.profile.name),
            response.content
        )
        # Test an item from social info
        self.assertIn(
            "Post on Facebook",
            response.content
        )
        self.assertIn(
            "Share on Twitter",
            response.content
        )
        # Test an item from certificate/org info
        self.assertIn(
            "a course of study offered by {partner_short_name}, "
            "an online learning initiative of "
            "{partner_long_name}.".format(
                partner_short_name=short_org_name,
                partner_long_name=long_org_name,
                platform_name='Test Microsite'
            ),
            response.content
        )
        # Test item from badge info
        self.assertIn(
            "Add to Mozilla Backpack",
            response.content
        )
        # Test item from microsite info
        self.assertIn(
            "http://www.testmicrosite.org/about-us",
            response.content
        )
        # Test course overrides
        self.assertIn(
            "/static/certificates/images/course_override_logo.png",
            response.content
        )