def test_alert_confirmation_uses_dispatcher(self, mock_dispatch): alert = ProductAlert.objects.create(email='*****@*****.**', key='dummykey', status=ProductAlert.UNCONFIRMED, product=self.product) send_alert_confirmation(alert) self.assertEqual(mock_dispatch.call_count, 1) self.assertEqual(mock_dispatch.call_args[0][0], '*****@*****.**')
def test_alert_confirmation_uses_dispatcher(self, mock_dispatch): alert = ProductAlert.objects.create( email='*****@*****.**', key='dummykey', status=ProductAlert.UNCONFIRMED, product=self.product ) send_alert_confirmation(alert) self.assertEqual(mock_dispatch.call_count, 1) self.assertEqual(mock_dispatch.call_args[0][0], '*****@*****.**')
def test_deprecated_notification_templates_work(self, mock_loader): """ This test can be removed when support for the deprecated templates is dropped. """ mock_loader.side_effect = self._load_deprecated_template with warnings.catch_warnings(record=True) as warning_list: warnings.simplefilter("always") alert = ProductAlert.objects.create( email='*****@*****.**', key='dummykey', status=ProductAlert.UNCONFIRMED, product=self.product) send_alert_confirmation(alert) # Check that warnings were raised self.assertTrue( any(item.category == RemovedInOscar20Warning for item in warning_list)) # Check that alerts were still sent self.assertEqual(len(mail.outbox), 1)
def test_deprecated_notification_templates_work(self, mock_loader): """ This test can be removed when support for the deprecated templates is dropped. """ mock_loader.side_effect = self._load_deprecated_template with warnings.catch_warnings(record=True) as warning_list: warnings.simplefilter("always") alert = ProductAlert.objects.create( email='*****@*****.**', key='dummykey', status=ProductAlert.UNCONFIRMED, product=self.product ) send_alert_confirmation(alert) # Check that warnings were raised self.assertTrue(any(item.category == RemovedInOscar20Warning for item in warning_list)) # Check that alerts were still sent self.assertEqual(len(mail.outbox), 1)
def form_valid(self, form): response = super(ProductAlertCreateView, self).form_valid(form) if self.object.is_anonymous: utils.send_alert_confirmation(self.object) return response
def form_valid(self, form): response = super().form_valid(form) if self.object.is_anonymous: utils.send_alert_confirmation(self.object) return response
def form_valid(self, form): response = super().form_valid(form) if self.object.is_anonymous: utils.send_alert_confirmation(self.object) return response
def form_valid(self, form): response = super(ProductAlertCreateView, self).form_valid(form) if self.object.is_anonymous: utils.send_alert_confirmation(self.object) return response