def test_set_then_unset_subscription_state(self):
     with utils.Namespace(self.namespace):
         self.assertSubscribed(self.EMAIL, self.namespace)
         unsubscribe.set_subscribed(self.EMAIL, True)
         self.assertSubscribed(self.EMAIL, self.namespace)
         unsubscribe.set_subscribed(self.EMAIL, False)
         self.assertUnsubscribed(self.EMAIL, self.namespace)
Exemplo n.º 2
0
 def test_set_then_unset_subscription_state(self):
     with utils.Namespace(self.namespace):
         self.assertSubscribed(self.EMAIL, self.namespace)
         unsubscribe.set_subscribed(self.EMAIL, True)
         self.assertSubscribed(self.EMAIL, self.namespace)
         unsubscribe.set_subscribed(self.EMAIL, False)
         self.assertUnsubscribed(self.EMAIL, self.namespace)
Exemplo n.º 3
0
    def test_rest_handler_discretely_does_not_mail_unsubscribed_users(self):
        # For privacy reasons the service should NOT email unsubscribed users,
        # but should report to the requestor that it did.
        unsubscribed_email = '*****@*****.**'
        unsubscribe.set_subscribed(unsubscribed_email, False)

        response = self._do_valid_email_list_post([unsubscribed_email])
        self.assertEquals(200, response['status'])
        self.assertEquals('OK, 1 messages sent', response['message'])
        self.assertEqual(0, self.send_async_count)
Exemplo n.º 4
0
    def test_rest_handler_discretely_does_not_mail_unsubscribed_users(self):
        # For privacy reasons the service should NOT email unsubscribed users,
        # but should report to the requestor that it did.
        unsubscribed_email = '*****@*****.**'
        unsubscribe.set_subscribed(unsubscribed_email, False)

        response = self._do_valid_email_list_post([unsubscribed_email])
        self.assertEquals(200, response['status'])
        self.assertEquals('OK, 1 messages sent', response['message'])
        self.assertEqual(0, self.send_async_count)
Exemplo n.º 5
0
    def test_subscribe_link_shown_to_unsubscribed_user(self):
        self.register()
        unsubscribe.set_subscribed(self.STUDENT_EMAIL, False)

        dom = self.parse_html_string(self.get(self.URL).body)
        subscribe_row = self._find_row(dom, 'Subscribe/Unsubscribe')
        td = subscribe_row.find('td')
        self.assertEquals('You are currently unsubscribed from invitations.',
                          td.text)
        link = td[0]
        self.assertEquals('Click here to re-subscribe.', link.text)

        unsubscribe_url = urlparse.urlparse(link.attrib['href'])
        self.assertEquals('/invitation_course/modules/unsubscribe',
                          unsubscribe_url.path)
        query = urlparse.parse_qs(unsubscribe_url.query)
        self.assertEquals(self.STUDENT_EMAIL, query['email'][0])
        self.assertEquals('resubscribe', query['action'][0])
Exemplo n.º 6
0
    def test_rest_handler_can_send_some_invitations_but_not_others(self):
        spammed_email = '*****@*****.**'
        response = self._do_valid_email_list_post([spammed_email])
        self.assertEquals(200, response['status'])
        self.assertEqual(1, self.send_async_count)

        self.send_async_count = 0

        unsubscribed_email = '*****@*****.**'
        unsubscribe.set_subscribed(unsubscribed_email, False)

        response = self._do_valid_email_list_post(
            ['*****@*****.**', unsubscribed_email, '*****@*****.**', spammed_email])
        self.assertEquals(400, response['status'])
        self.assertIn('Not all messages were sent (3 / 4)', response['message'])
        self.assertIn(
            'You have already sent an invitation email to "*****@*****.**"',
            response['message'])
        self.assertEqual(2, self.send_async_count)
    def test_subscribe_link_shown_to_unsubscribed_user(self):
        self.register()
        unsubscribe.set_subscribed(self.STUDENT_EMAIL, False)

        dom = self.parse_html_string(self.get(self.URL).body)
        subscribe_row = self._find_row(dom, 'Subscribe/Unsubscribe')
        td = subscribe_row.find('td')
        self.assertEquals(
            'You are currently unsubscribed from invitations.', td.text)
        link = td[0]
        self.assertEquals(
            'Click here to re-subscribe.', link.text)

        unsubscribe_url = urlparse.urlparse(link.attrib['href'])
        self.assertEquals(
            '/invitation_course/modules/unsubscribe', unsubscribe_url.path)
        query = urlparse.parse_qs(unsubscribe_url.query)
        self.assertEquals(self.STUDENT_EMAIL, query['email'][0])
        self.assertEquals('resubscribe', query['action'][0])
Exemplo n.º 8
0
    def test_rest_handler_can_send_some_invitations_but_not_others(self):
        spammed_email = '*****@*****.**'
        response = self._do_valid_email_list_post([spammed_email])
        self.assertEquals(200, response['status'])
        self.assertEqual(1, self.send_async_count)

        self.send_async_count = 0

        unsubscribed_email = '*****@*****.**'
        unsubscribe.set_subscribed(unsubscribed_email, False)

        response = self._do_valid_email_list_post(
            ['*****@*****.**', unsubscribed_email, '*****@*****.**', spammed_email])
        self.assertEquals(400, response['status'])
        self.assertIn('Not all messages were sent (3 / 4)', response['message'])
        self.assertIn(
            'You have already sent an invitation email to "*****@*****.**"',
            response['message'])
        self.assertEqual(2, self.send_async_count)