'Tests custom template renders properly with unicode data.'

@ddt.data(True, False)
def test_certificate_custom_template_with_unicode_data(self, custom_certs_enabled):

    mode = 'honor'
    self._add_course_certificates(count=1, signatory_count=2)
    self._create_custom_template(mode=mode)
    with patch.dict('django.conf.settings.FEATURES', {'CERTIFICATES_HTML_VIEW': True, 'CUSTOM_CERTIFICATE_TEMPLATES_ENABLED': custom_certs_enabled}):
        test_url = get_certificate_url(user_id=self.user.id, course_id=unicode(self.course.id))
        with patch.dict('django.conf.settings.SOCIAL_SHARING_SETTINGS', {'CERTIFICATE_TWITTER': True, 'CERTIFICATE_TWITTER_TEXT': u'n\u1ec1n    t\u1ea3ng    h\u1ecdc    t\u1eadp'}):
            with patch('django.http.HttpRequest.build_absolute_uri') as mock_abs_uri:
                mock_abs_uri.return_value = '='.join(['http://localhost/?param', u'\xe9'])
                with patch('certificates.api.get_course_organizations') as mock_get_orgs:
                    mock_get_orgs.return_value = []
                    response = self.client.get(test_url)
                    self.assertEqual(response.status_code, 200)
                    if custom_certs_enabled:
                        self.assertContains(response, 'mode:    {}'.format(mode))
                    else:
                        self.assertContains(response, 'Tweet    this    Accomplishment')
                    self.assertContains(response, 'https://twitter.com/intent/tweet')
