Exemplo n.º 1
0
 def test_success(self):
     """Ensure the watch deletes and view says "yay" when all goes well."""
     w = watch(save=True)
     response = self.client.post(
         reverse('tidings.unsubscribe', args=[w.pk]) + '?s=' + w.secret)
     self.assertContains(response, '<h1>Unsubscribed</h1>')
     self.assertEqual(0, Watch.objects.count())
Exemplo n.º 2
0
 def unsubscribe_url(self):
     """Return the absolute URL to visit to delete me."""
     server_relative = ('%s?s=%s' % (reverse('tidings.unsubscribe',
                                             args=[self.pk]),
                                     self.secret))
     return 'https://%s%s' % (Site.objects.get_current().domain,
                              server_relative)
Exemplo n.º 3
0
 def test_success(self):
     """Ensure the watch deletes and view says "yay" when all goes well."""
     w = watch(save=True)
     response = self.client.post(
         reverse('tidings.unsubscribe', args=[w.pk]) + '?s=' + w.secret)
     self.assertContains(response, '<h1>Unsubscribed</h1>')
     self.assertEqual(0, Watch.objects.count())
Exemplo n.º 4
0
 def test_wrong_secret(self):
     """Assert it complains when an incorrect secret is given."""
     w = watch(save=True)
     for method in [self.client.get, self.client.post]:
         response = method(
             reverse('tidings.unsubscribe', args=[w.pk]) + '?s=WRONGwrong')
         self.assertContains(response, FAILURE_STRING)
Exemplo n.º 5
0
 def test_wrong_secret(self):
     """Assert it complains when an incorrect secret is given."""
     w = watch(save=True)
     for method in [self.client.get, self.client.post]:
         response = method(
             reverse('tidings.unsubscribe', args=[w.pk]) + '?s=WRONGwrong')
         self.assertContains(response, FAILURE_STRING)
Exemplo n.º 6
0
 def test_no_such_watch(self):
     """Assert it complains when asked for a nonexistent Watch."""
     for method in [self.client.get, self.client.post]:
         response = method(reverse('tidings.unsubscribe', args=[33]))
         self.assertContains(response, FAILURE_STRING)
Exemplo n.º 7
0
 def test_confirmation(self):
     """Ensure the confirmation page renders if you feed it valid data."""
     w = watch(save=True)
     response = self.client.get(
         reverse('tidings.unsubscribe', args=[w.pk]) + '?s=' + w.secret)
     self.assertContains(response, 'Are you sure you want to unsubscribe?')
Exemplo n.º 8
0
 def test_no_such_watch(self):
     """Assert it complains when asked for a nonexistent Watch."""
     for method in [self.client.get, self.client.post]:
         response = method(reverse('tidings.unsubscribe', args=[33]))
         self.assertContains(response, FAILURE_STRING)
Exemplo n.º 9
0
 def test_confirmation(self):
     """Ensure the confirmation page renders if you feed it valid data."""
     w = watch(save=True)
     response = self.client.get(
         reverse('tidings.unsubscribe', args=[w.pk]) + '?s=' + w.secret)
     self.assertContains(response, 'Are you sure you want to unsubscribe?')