def test_computer_monitor_blurbs(): """ This email was generated by google alerts in production for the alert "computer monitors" """ alert = create_alert() blurbs = alerts.create_blurbs(compmsg, alert)
def test_computer_monitor_stubs(): """ This email was generated by google alerts in production for the alert "computer monitors". This tests the stubs function. """ alert = create_alert() stubs = alerts.get_html_stubs(compmsg.body()) assert len(stubs) == 26
def test_computer_monitor_raw(): """ This email was generated by google alerts in production for the alert "computer monitors". This tests getting the raw alerts. """ alert = create_alert() stubs = alerts.get_html_stubs(compmsg.body()) rawAlerts = [alerts.get_raw_alert(stub) for stub in stubs] assert len(rawAlerts) == 26
def test_good_confirmation(msg=None): """ This message should move the state into ALERTING. """ alert = create_alert() addr = "*****@*****.**" % alert.id if not msg: msg = MailRequest('fakepeer', sender, addr, open(home("tests/data/emails/confirmation.msg")).read()) msg['to'] = addr Router.deliver(msg) q = queue.Queue(email('run/alerts')) assert q.count() == 0 assert_in_state('app.handlers.alerts', msg['to'], sender, 'ALERTING')
def test_incoming_alert(): """ Verify an incoming alert generates the correct database records. """ alert = create_alert() msg = MailRequest('fakepeer', sender, "*****@*****.**" % alert.id, open(home("tests/data/emails/alerts.msg")).read()) msg['to'] = "*****@*****.**" % alert.id Router.deliver(msg) #Should error out in the alerts.py handlers module in CONFIRMING #because these messages are dumped in the alertsq to be handled asyncronously, #but the testing environment just sends it to both modules at the same time. q = queue.Queue(email('run/error')) assert q.count() == 1 assert len(Blurb.objects.all()) == 26, "There are %s blurbs." % len(Blurb.objects.all())
def test_confirm_then_alert(): """ An alert sent after an account is confirmed should go right into ALERTING and alert objects should be created in the database. """ alert = create_alert() addr = "*****@*****.**" % alert.id confirm = MailRequest('fakepeer', sender, addr, open(home("tests/data/emails/confirmation.msg")).read()) confirm['to'] = addr test_good_confirmation(msg=confirm) alertsmsg = MailRequest('fakepeer', "different@sender", addr, open(home("tests/data/emails/alerts.msg")).read()) alertsmsg['to'] = addr Router.deliver(alertsmsg) # there are 10 alerts in this alert email. since this is the test environment it will be dumped # into the alerts queue automatically, which will create the 10 alerts. Then it should be processed # by the alerts handler module, dumped into the queue again, thereby upping the alerts queue by one. assert len(Blurb.objects.all()) == 26, "There are %s blurbs." % len(Blurb.objects.all()) q = queue.Queue(email('run/alerts')) assert q.count() == 1