def test_linked_in_url_with_cert_name_override(self, cert_mode,
                                                   expected_cert_name):
        config = LinkedInAddToProfileConfigurationFactory()

        # We can switch to this once edx-platform reaches Python 3.8
        # expected_url = (
        #     'https://www.linkedin.com/profile/add?startTask=CERTIFICATION_NAME&'
        #     'name={platform}+{cert_name}&certUrl={cert_url}&'
        #     'organizationId={company_identifier}'
        # ).format(
        #     platform=quote(settings.PLATFORM_NAME.encode('utf-8')),
        #     cert_name=expected_cert_name,
        #     cert_url=quote(self.CERT_URL, safe=''),
        #     company_identifier=config.company_identifier,
        # )

        with with_site_configuration_context(
                configuration=self.SITE_CONFIGURATION):
            actual_url = config.add_to_profile_url(self.COURSE_NAME, cert_mode,
                                                   self.CERT_URL)

            # We can switch to this instead of the assertIn once edx-platform reaches Python 3.8
            # There was a problem with dict ordering in the add_to_profile_url function that will go away then.
            # self.assertEqual(actual_url, expected_url)

            assert 'https://www.linkedin.com/profile/add?startTask=CERTIFICATION_NAME' in actual_url
            assert f'&name={quote(settings.PLATFORM_NAME.encode("utf-8"))}+{expected_cert_name}' in actual_url
            assert '&certUrl={cert_url}'.format(
                cert_url=quote(self.CERT_URL, safe='')) in actual_url
            assert '&organizationId={org_id}'.format(
                org_id=config.company_identifier) in actual_url
Exemple #2
0
 def setUpClass(cls):
     BaseCoursewareTests.setUpClass()
     cls.course.tabs.append(ExternalLinkCourseTab.load('external_link', name='Zombo', link='http://zombo.com'))
     cls.course.tabs.append(
         ExternalLinkCourseTab.load('external_link', name='Hidden', link='http://hidden.com', is_hidden=True)
     )
     cls.store.update_item(cls.course, cls.user.id)
     LinkedInAddToProfileConfigurationFactory.create()
Exemple #3
0
 def setUpClass(cls):
     BaseCoursewareTests.setUpClass()
     cls.course.tabs.append(ExternalLinkCourseTab.load('external_link', name='Zombo', link='http://zombo.com'))
     cls.course.tabs.append(
         ExternalLinkCourseTab.load('external_link', name='Hidden', link='http://hidden.com', is_hidden=True)
     )
     cls.store.update_item(cls.course, cls.user.id)
     LinkedInAddToProfileConfigurationFactory.create()
     CourseModeFactory(course_id=cls.course.id, mode_slug=CourseMode.AUDIT)
     CourseModeFactory(
         course_id=cls.course.id,
         mode_slug=CourseMode.VERIFIED,
         expiration_datetime=datetime(3028, 1, 1),
         min_price=149,
         sku='ABCD1234',
     )
    def test_post_to_linkedin_visibility(self):
        """
        Verifies that the post certificate to linked button
        does not appear by default (when config is not set)
        Then Verifies that the post certificate to linked button appears
        as expected once a config is set
        """
        self._create_certificate('honor')

        # until we set up the configuration, the LinkedIn action
        # button should not be visible
        self._check_linkedin_visibility(False)

        LinkedInAddToProfileConfigurationFactory()
        # now we should see it
        self._check_linkedin_visibility(True)