@ -146,23 +146,6 @@ class NotifyTestCase(BaseTestCase): | |||
self.assertEqual(n.error, "Email not verified") | |||
self.assertEqual(len(mail.outbox), 0) | |||
@override_settings(USE_PAYMENTS=True) | |||
def test_email_contains_upgrade_notice(self): | |||
self._setup_data("email", "[email protected]", status="up") | |||
self.profile.team_access_allowed = False | |||
self.profile.save() | |||
self.channel.notify(self.check) | |||
n = Notification.objects.get() | |||
self.assertEqual(n.error, "") | |||
# Check is up, payments are enabled, and the user does not have team | |||
# access: the email should contain upgrade note | |||
message = mail.outbox[0] | |||
html, _ = message.alternatives[0] | |||
assert "/pricing/" in html | |||
@patch("hc.api.transports.requests.request") | |||
def test_pd(self, mock_post): | |||
self._setup_data("pd", "123") | |||
@ -0,0 +1,38 @@ | |||
from hc.api.models import Channel | |||
from hc.test import BaseTestCase | |||
class UnsubscribeEmailTestCase(BaseTestCase): | |||
def setUp(self): | |||
super(UnsubscribeEmailTestCase, self).setUp() | |||
self.channel = Channel(user=self.alice, kind="email") | |||
self.channel.value = "[email protected]" | |||
self.channel.save() | |||
def test_it_works(self): | |||
token = self.channel.make_token() | |||
url = "/integrations/%s/unsub/%s/" % (self.channel.code, token) | |||
r = self.client.get(url) | |||
self.assertContains(r, "has been unsubscribed", status_code=200) | |||
q = Channel.objects.filter(code=self.channel.code) | |||
self.assertEqual(q.count(), 0) | |||
def test_it_checks_token(self): | |||
url = "/integrations/%s/unsub/faketoken/" % self.channel.code | |||
r = self.client.get(url) | |||
self.assertContains(r, "link you just used is incorrect", | |||
status_code=200) | |||
def test_it_checks_channel_kind(self): | |||
self.channel.kind = "webhook" | |||
self.channel.save() | |||
token = self.channel.make_token() | |||
url = "/integrations/%s/unsub/%s/" % (self.channel.code, token) | |||
r = self.client.get(url) | |||
self.assertEqual(r.status_code, 400) |
@ -0,0 +1,19 @@ | |||
{% extends "base.html" %} | |||
{% load hc_extras %} | |||
{% block content %} | |||
<div class="row"> | |||
<div class="col-sm-6 col-sm-offset-3"> | |||
<div class="hc-dialog"> | |||
<h1>Unsubscribed</h1> | |||
<div class="dialog-body"> | |||
<p> | |||
Your email address has been unsubscribed from | |||
{% site_name %} notifications. | |||
</p> | |||
</div> | |||
</div> | |||
</div> | |||
</div> | |||
{% endblock %} |