def subscribe(request): from django_subs.utils import subscribe subscribe( request.POST['subs_id'], request.POST['email'], ) return redirect(request.POST['next'])
def testSendMessageUsesSimpleTemplate(self): clear() hash = subscribe('blah', '*****@*****.**') subscribe('blah', '*****@*****.**') subscribe('minor', '*****@*****.**') send_message('blah', 'subject', 'Test message') self.assertEqual(2, len(mail.outbox)) self.assertEqual(['*****@*****.**'], mail.outbox[0].to) self.assertEqual(['*****@*****.**'], mail.outbox[1].to) body = mail.outbox[0].body self.assert_('Test message' in body) self.assert_(hash in body)
def testUnSubscribeViaView(self): c = Client() hash = subscribe('blah-minor', '*****@*****.**') self.assertEqual(1, Subscription.objects.count()) response = c.post(reverse('unsubscribe'), dict(hash=hash, next='/')) self.assertRedirects(response, '/') self.assertEqual(0, Subscription.objects.count())
def testUnSubscribeViaView(self): c = Client() hash = subscribe('blah-minor', '*****@*****.**') self.assertEqual(1, Subscription.objects.count()) response = c.post( reverse('unsubscribe'), dict( hash = hash, next = '/' ) ) self.assertRedirects(response, '/') self.assertEqual(0, Subscription.objects.count())
def testUnSubscribeTwiceViaFunction(self): hash = subscribe('blah-minor', '*****@*****.**') self.assertEqual(1, Subscription.objects.count()) unsubscribe(hash) self.assertEqual(0, Subscription.objects.count())