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_get_html_stubs(): """ Given some html, return a list of html stubs that represent alerts. """ alertsmsg = MailRequest( "fakepeer", sender, "*****@*****.**", open(home("tests/data/emails/alerts.msg")).read() ) stubs = alerts.get_html_stubs(alertsmsg.body()) assert len(stubs) == 26
def test_get_raw_alert(): """ Given a chunk of html, turn it into a python dictionary we can use to populate a database record. """ alertsmsg = MailRequest( "fakepeer", sender, "*****@*****.**", open(home("tests/data/emails/alerts.msg")).read() ) stub = alerts.get_html_stubs(alertsmsg.body())[1] alert = alerts.get_raw_alert(stub) assert alert.has_key("blurb") assert alert["title"].startswith("Audio reveals swipes at Obama, other Illinois Democrats") assert alert["source"] == "Chicago Tribune", "Expected Chicago Tribune, source is actually %s" % alert["source"] assert alert["byline"] == "" alert[ "url" ] == "http://www.chicagotribune.com/news/local/blagojevich/ct-met-blagojevich-trial-0704-20100704,0,3385819.story" stub = alerts.get_html_stubs(alertsmsg.body())[0] alert = alerts.get_raw_alert(stub) assert alert["byline"] == "" assert alert["url"] == "http://www.foxnews.com/politics/2010/07/03/obama-announces-b-grants-clean-energy-jobs/"