예제 #1
0
    def assertReactivateEmailSent(self, email_user):
        """
        Assert that the correct reactivation email has been sent
        """
        context = generate_activation_email_context(self.user, self.registration)

        self.assertEmailUser(
            email_user,
            'emails/activation_email_subject.txt',
            context,
            'emails/activation_email.txt',
            context
        )

        # Thorough tests for safe_get_host are elsewhere; here we just want a quick URL sanity check
        request = RequestFactory().post('unused_url')
        request.user = self.user
        request.META['HTTP_HOST'] = "aGenericValidHostName"
        self.append_allowed_hosts("aGenericValidHostName")

        with patch('edxmako.request_context.get_current_request', return_value=request):
            body = render_to_string('emails/activation_email.txt', context)
            host = safe_get_host(request)

        self.assertIn(host, body)
예제 #2
0
    def assertReactivateEmailSent(self, email_user):
        """
        Assert that the correct reactivation email has been sent
        """
        context = generate_activation_email_context(self.user, self.registration)

        self.assertEmailUser(
            email_user,
            'emails/activation_email_subject.txt',
            context,
            'emails/activation_email.txt',
            context
        )

        # Thorough tests for safe_get_host are elsewhere; here we just want a quick URL sanity check
        request = RequestFactory().post('unused_url')
        request.user = self.user
        request.META['HTTP_HOST'] = "aGenericValidHostName"
        self.append_allowed_hosts("aGenericValidHostName")

        with patch('edxmako.request_context.get_current_request', return_value=request):
            body = render_to_string('emails/activation_email.txt', context)
            host = safe_get_host(request)

        self.assertIn(host, body)