def test_get_context_data_without_request_no_context(self): email_message = BaseEmailMessage(template_name='text_mail.html') context = email_message.get_context_data() self.assertEquals(context['domain'], '') self.assertEquals(context['protocol'], 'http') self.assertEquals(context['site_name'], '') self.assertEquals(context['user'], None)
def test_get_context_data_without_request_user_context(self): user = AnonymousUser() email_message = BaseEmailMessage(context={'user': user}, template_name='text_mail.html') context = email_message.get_context_data() self.assertEquals(context['domain'], '') self.assertEquals(context['protocol'], 'http') self.assertEquals(context['site_name'], '') self.assertEquals(context['user'], user)
def test_get_context_data_with_secure_request(self, is_secure_mock): is_secure_mock.return_value = True request = self.factory.get('/') request.user = AnonymousUser() email_message = BaseEmailMessage(request=request, template_name='text_mail.html') context = email_message.get_context_data() site = get_current_site(request) self.assertEquals(context['domain'], site.domain) self.assertEquals(context['protocol'], 'https') self.assertEquals(context['site_name'], site.name) self.assertEquals(context['user'], request.user)