Exemplo n.º 1
0
	def setUp(self):
		self.view = SubscriptionView()
		self.user_email = '*****@*****.**'
		self.site = Site.objects.get_current()
		self.site.name = "example.com"
		self.site.domain = "example.com"
		self.site.save()
		user = User.objects.create(username=self.user_email, email=self.user_email)
		mailing_list = MailingList.objects.create(name="Hello World", local_part="hello-world", domain=self.site)
		metadata = ListUserMetadata.objects.create(user=user, mailing_list=mailing_list)
		self.view.user = user
		self.view.mailing_list = mailing_list
		self.view.metadata = metadata
Exemplo n.º 2
0
class SubscriptionViewTestCase(TestCase):
	def setUp(self):
		self.view = SubscriptionView()
		self.user_email = '*****@*****.**'
		self.site = Site.objects.get_current()
		self.site.name = "example.com"
		self.site.domain = "example.com"
		self.site.save()
		user = User.objects.create(username=self.user_email, email=self.user_email)
		mailing_list = MailingList.objects.create(name="Hello World", local_part="hello-world", domain=self.site)
		metadata = ListUserMetadata.objects.create(user=user, mailing_list=mailing_list)
		self.view.user = user
		self.view.mailing_list = mailing_list
		self.view.metadata = metadata
	
	def test_email_context(self):
		context = self.view.get_email_context()
		self.assertTrue(self.view.token_generator.check_token(self.view.metadata, context['token']))
		del context['token']
		expected_context = {
			'email': self.user_email,
			'mid': int_to_base36(self.view.metadata.pk),
			'metadata': self.view.metadata,
			'user': self.view.user,
			'mailing_list': self.view.mailing_list,
			'site_name': "example.com",
			'domain': "example.com",
			'protocol': 'http'
		}
		self.assertEqual(context, expected_context)
	
	def test_get_from_email(self):
		self.assertEqual(self.view.get_from_email(), "*****@*****.**")
	
	def test_get_to_addresses(self):
		self.assertEqual(self.view.get_to_addresses(), [self.user_email])
Exemplo n.º 3
0
from django.conf.urls.defaults import url, patterns

from kiki.views import SubscriptionView, SubscriptionConfirmationView


urlpatterns = patterns('',
	url(r'^$', SubscriptionView.as_view(), name='kiki_subscription'),
	url(r'^confirm/(?P<midb36>[0-9A-Za-z]{1,13})-(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})$', SubscriptionConfirmationView.as_view(), name='kiki_subscription_confirm')
)