@@ -38,28 +38,20 @@ class LinkedInAddToProfileUrlTests(TestCase):
3838 def test_linked_in_url (self , cert_mode , expected_cert_name ):
3939 config = LinkedInAddToProfileConfigurationFactory ()
4040
41- # We can switch to this once edx-platform reaches Python 3.8
42- # expected_url = (
43- # 'https://www.linkedin.com/profile/add?startTask=CERTIFICATION_NAME&'
44- # 'name={platform}+{cert_name}&certUrl={cert_url}&'
45- # 'organizationId={company_identifier}'
46- # ).format(
47- # platform=quote(settings.PLATFORM_NAME.encode('utf-8')),
48- # cert_name=expected_cert_name,
49- # cert_url=quote(self.CERT_URL, safe=''),
50- # company_identifier=config.company_identifier,
51- # )
41+ expected_url = (
42+ 'https://www.linkedin.com/profile/add?startTask=CERTIFICATION_NAME&'
43+ 'name={platform}+{cert_name}&certUrl={cert_url}&'
44+ 'organizationId={company_identifier}'
45+ ).format (
46+ platform = quote (settings .PLATFORM_NAME .encode ('utf-8' )),
47+ cert_name = expected_cert_name ,
48+ cert_url = quote (self .CERT_URL , safe = '' ),
49+ company_identifier = config .company_identifier ,
50+ )
5251
5352 actual_url = config .add_to_profile_url (self .COURSE_NAME , cert_mode , self .CERT_URL )
5453
55- # We can switch to this instead of the assertIn once edx-platform reaches Python 3.8
56- # There was a problem with dict ordering in the add_to_profile_url function that will go away then.
57- # self.assertEqual(actual_url, expected_url)
58-
59- assert 'https://www.linkedin.com/profile/add?startTask=CERTIFICATION_NAME' in actual_url
60- assert f'&name={ quote (settings .PLATFORM_NAME .encode ("utf-8" ))} +{ expected_cert_name } ' in actual_url
61- assert '&certUrl={cert_url}' .format (cert_url = quote (self .CERT_URL , safe = '' )) in actual_url
62- assert f'&organizationId={ config .company_identifier } ' in actual_url
54+ self .assertEqual (actual_url , expected_url )
6355
6456 @ddt .data (
6557 ('honor' , 'Honor+Code+Credential+for+Test+Course+%E2%98%83' ),
@@ -72,26 +64,18 @@ def test_linked_in_url(self, cert_mode, expected_cert_name):
7264 def test_linked_in_url_with_cert_name_override (self , cert_mode , expected_cert_name ):
7365 config = LinkedInAddToProfileConfigurationFactory ()
7466
75- # We can switch to this once edx-platform reaches Python 3.8
76- # expected_url = (
77- # 'https://www.linkedin.com/profile/add?startTask=CERTIFICATION_NAME&'
78- # 'name={platform}+{cert_name}&certUrl={cert_url}&'
79- # 'organizationId={company_identifier}'
80- # ).format(
81- # platform=quote(settings.PLATFORM_NAME.encode('utf-8')),
82- # cert_name=expected_cert_name,
83- # cert_url=quote(self.CERT_URL, safe=''),
84- # company_identifier=config.company_identifier,
85- # )
67+ expected_url = (
68+ 'https://www.linkedin.com/profile/add?startTask=CERTIFICATION_NAME&'
69+ 'name={platform}+{cert_name}&certUrl={cert_url}&'
70+ 'organizationId={company_identifier}'
71+ ).format (
72+ platform = quote (settings .PLATFORM_NAME .encode ('utf-8' )),
73+ cert_name = expected_cert_name ,
74+ cert_url = quote (self .CERT_URL , safe = '' ),
75+ company_identifier = config .company_identifier ,
76+ )
8677
8778 with with_site_configuration_context (configuration = self .SITE_CONFIGURATION ):
8879 actual_url = config .add_to_profile_url (self .COURSE_NAME , cert_mode , self .CERT_URL )
8980
90- # We can switch to this instead of the assertIn once edx-platform reaches Python 3.8
91- # There was a problem with dict ordering in the add_to_profile_url function that will go away then.
92- # self.assertEqual(actual_url, expected_url)
93-
94- assert 'https://www.linkedin.com/profile/add?startTask=CERTIFICATION_NAME' in actual_url
95- assert f'&name={ quote (settings .PLATFORM_NAME .encode ("utf-8" ))} +{ expected_cert_name } ' in actual_url
96- assert '&certUrl={cert_url}' .format (cert_url = quote (self .CERT_URL , safe = '' )) in actual_url
97- assert f'&organizationId={ config .company_identifier } ' in actual_url
81+ self .assertEqual (actual_url , expected_url )
0 commit comments