def test_import(self): self.assertEquals(len(subscribe.SubscriptionStorage()._data), 0) self.assertEquals(len(api.portal.get_registry_record(reg_key)), 0) self.request.form.update({ 'form.widgets.csv_upload': u'name,email,phone_number,phone_number_confirmed,confirmed,code,created,captcha,categories\nUser,[email protected],,False,True,,,,"News"', # noqa 'form.buttons.import': u'Import' }) form = ImportSubscribersForm(self.portal, self.request) form() self.assertEquals(len(subscribe.SubscriptionStorage()._data), 1) self.assertEquals(len(api.portal.get_registry_record(reg_key)), 1)
def test_user_subscribes(self): responses.add(responses.POST, "https://www.google.com/recaptcha/api/siteverify", body='{"success": true}', content_type="application/json") self.request.form.update({ 'form.widgets.name': u'Foobar', 'form.widgets.email': u'*****@*****.**', 'g-recaptcha-response': u'foobar', 'form.buttons.subscribe': 'Subscribe' }) form = SubscribeForm(self.portal, self.request) form() mailhost = self.portal.MailHost self.assertEqual(len(mailhost.messages), 1) self.assertEquals(len(subscribe.SubscriptionStorage()._data), 1)
def test_category_match(self): subscribe.register('*****@*****.**', {'categories': [u'A']}) subscriber = subscribe.get('*****@*****.**') subscribe.confirm('*****@*****.**', subscriber['code']) responses.add(responses.POST, "https://www.google.com/recaptcha/api/siteverify", body='{"success": true}', content_type="application/json") self.request.form.update({ 'form.widgets.subject': u'TEST', 'form.widgets.send_to_categories': [u'A'], 'form.widgets.body': 'Words words words', 'form.widgets.body_plain': 'Words words words', 'form.buttons.send2': 'Send' }) form = SendEmailSubscribersForm(self.portal, self.request) form() mailhost = self.portal.MailHost self.assertEqual(len(mailhost.messages), 1) self.assertEquals(len(subscribe.SubscriptionStorage()._data), 1)