def test_all_england_alerts_sent(self):
        factory = DataFactory()

        # Create an All England bookmark, send alerts, and make sure one email
        # is sent to correct user
        bookmark = factory.create_org_bookmark(None)
        call_command(CMD_NAME)
        self.assertEqual(len(mail.outbox), 1)
        self.assertEqual(mail.outbox[0].to, [bookmark.user.email])
Beispiel #2
0
    def test_pcn_alerts_sent(self):
        """Create a PCN bookmark, send alerts, and make sure an email is sent
        to correct user, and that its contents mention PCNs

        """
        factory = DataFactory()
        pcn = PCN.objects.get(pk="E00000011")
        bookmark = factory.create_org_bookmark(pcn)
        call_command(CMD_NAME)
        self.assertEqual(len(mail.outbox), 1)
        self.assertEqual(mail.outbox[0].to, [bookmark.user.email])
        self.assertIn("PCN", mail.outbox[0].body)
Beispiel #3
0
    def test_send_alerts(self):
        factory = DataFactory()

        # Create a bookmark, send alerts, and make sure one email is sent to
        # correct user
        bookmark = factory.create_org_bookmark(None)
        call_command('send_all_england_alerts')
        self.assertEqual(len(mail.outbox), 1)
        self.assertEqual(mail.outbox[0].to, [bookmark.user.email])

        # Create another bookmark, send alerts again and make sure email is
        # only sent to new user
        mail.outbox = []
        bookmark2 = factory.create_org_bookmark(None)
        call_command('send_all_england_alerts')
        self.assertEqual(len(mail.outbox), 1)
        self.assertEqual(mail.outbox[0].to, [bookmark2.user.email])

        # Try sending alerts again and make sure no emails are sent
        mail.outbox = []
        call_command('send_all_england_alerts')
        self.assertEqual(len(mail.outbox), 0)