def test_vimeo(): regex = 'Title: (.*?) by (.*?) \[%s - %s likes - %s views - %s]' % ( lengh_str_regex, views_str_regex, views_str_regex, age_str_regex) msg = 'http://vimeo.com/29996808' module_urltitle.init(bot) check_re(regex, module_urltitle.handle_url(bot, None, "#channel", msg, msg)[1])
def test_eleven(): msg = "http://en.wikipedia.org/wiki/Edison_Arantes_do_Nascimento" module_urltitle.init(bot) eq_( ("#channel", u"Title: Edson Arantes do Nascimento, better known as Pelé, is a retired Brazilian footballer."), module_urltitle.handle_url(bot, None, "#channel", msg, msg), )
def test_youtube(): regex = 'Title: (.*?) by (.*?) \[%s - \[\** *\] - %s views - %s( - XXX)?\]' % ( lengh_str_regex, views_str_regex, age_str_regex) msg = "http://www.youtube.com/watch?v=awsolTK175c" module_urltitle.init(bot) check_re(regex, module_urltitle.handle_url(bot, None, "#channel", msg, msg)[1])
def test_seven(): msg = "http://en.wikipedia.org/wiki/Ramon_Llull" module_urltitle.init(bot) eq_( ("#channel", u"Title: Ramon Llull was a Majorcan writer and philosopher, logician and a Franciscan tertiary."), module_urltitle.handle_url(bot, None, "#channel", msg, msg), )
def test_wiki_en(): msg = "http://en.wikipedia.org/wiki/IPhone" module_urltitle.init(bot) eq_(( "#channel", "Title: The iPhone is a line of smartphones designed and marketed by Apple Inc." ), module_urltitle.handle_url(bot, None, "#channel", msg, msg))
def test_six(): msg = "http://fi.wikipedia.org/wiki/Birger_Ek" module_urltitle.init(bot) eq_( ("#channel", u"Title: Rolf Birger Ek oli suomalainen lentäjä ja Mannerheim-ristin ritari."), module_urltitle.handle_url(bot, None, "#channel", msg, msg), )
def test_areena_series(botmock): regex = u"Title: Kummeli \[SERIES - 54 episodes - latest episode: %s\]" % ( age_str_regex) msg = "http://areena.yle.fi/1-3339547" check_re( regex, module_urltitle.handle_url(botmock, None, "#channel", msg, msg)[1])
def test_areena_not_available(botmock): regex = u"Title: (.*?) \[%s - %s - not available\]" % ( length_str_regex, age_str_regex, ) msg = "http://areena.yle.fi/1-2372901" check_re(regex, module_urltitle.handle_url(botmock, None, "#channel", msg, msg)[1])
def test_google_play_music(): msg = 'https://play.google.com/music/m/Tkyqfh5koeirtbi76b2tsee6e2y' module_urltitle.init(bot) responses = [('#channel', 'Title: Villiviini - Ultra Bra'), None] ok_( module_urltitle.handle_url(bot, None, "#channel", msg, msg) in responses)
def test_iltasanomat(): msg = "http://www.iltasanomat.fi/viihde/art-1288596309269.html" module_urltitle.init(bot) eq_(( "#channel", "Title: Muistatko Mari Sainion juontaman sarjan, josta sai palkinnoksi isdn-liittymän?" ), module_urltitle.handle_url(bot, None, "#channel", msg, msg))
def test_liveleak(): regex = 'Title: (.*?) by (.*?) \[%s views - Jul-23-2013 - tags\: sword, cut, hand, watermelon, fail\]' % ( views_str_regex) msg = 'http://www.liveleak.com/view?i=f8e_1374614129' module_urltitle.init(bot) check_re(regex, module_urltitle.handle_url(bot, None, "#channel", msg, msg)[1])
def test_seven(): msg = "http://en.wikipedia.org/wiki/Ramon_Llull" module_urltitle.init(bot) eq_(( "#channel", u"Title: Ramon Llull, T.O.S.F. was a Majorcan writer and philosopher, logician and a Franciscan tertiary." ), module_urltitle.handle_url(bot, None, "#channel", msg, msg))
def test_six(): msg = "http://fi.wikipedia.org/wiki/Birger_Ek" module_urltitle.init(bot) eq_(( "#channel", u"Title: Rolf Birger Ek oli suomalainen lentäjä ja Mannerheim-ristin ritari." ), module_urltitle.handle_url(bot, None, "#channel", msg, msg))
def test_two(): msg = "http://fi.wikipedia.org/wiki/DTMF" module_urltitle.init(bot) eq_(( "#channel", u"Title: DTMF on puhelinlaitteissa käytetty numeroiden äänitaajuusvalintatapa." ), module_urltitle.handle_url(bot, None, "#channel", msg, msg))
def test_wiki_en(): msg = "http://en.wikipedia.org/wiki/IPhone" module_urltitle.init(bot) eq_( ("#channel", "Title: iPhone is a line of smartphones designed and marketed by Apple Inc."), module_urltitle.handle_url(bot, None, "#channel", msg, msg), )
def test_four(): msg = "http://en.wikipedia.org/wiki/Dynamo_(magician)" module_urltitle.init(bot) eq_(( "#channel", u"Title: Steven Frayne, commonly known by his stage name \"Dynamo\", is an English magician, best known for his show Dynamo: Magician Impossible." ), module_urltitle.handle_url(bot, None, "#channel", msg, msg))
def test_two(): msg = "http://fi.wikipedia.org/wiki/DTMF" module_urltitle.init(bot) eq_( ("#channel", u"Title: DTMF on puhelinlaitteissa käytetty numeroiden äänitaajuusvalintatapa."), module_urltitle.handle_url(bot, None, "#channel", msg, msg), )
def test_liveleak(): regex = "Title: (.*?) by (.*?) \[%s views - Jul-23-2013 - tags\: sword, cut, hand, watermelon, fail\]" % ( views_str_regex ) msg = "http://www.liveleak.com/view?i=f8e_1374614129" module_urltitle.init(bot) check_re(regex, module_urltitle.handle_url(bot, None, "#channel", msg, msg)[1])
def test_iltalehti(): msg = "http://www.iltalehti.fi/ulkomaat/2013072917307393_ul.shtml" module_urltitle.init(bot) eq_( ("#channel", "Title: Saksassa syntyi jättivauva - yli kuusi kiloa!"), module_urltitle.handle_url(bot, None, "#channel", msg, msg), )
def test_eight(): msg = "http://en.wikipedia.org/wiki/Lazarus_of_Bethany#In_culture" module_urltitle.init(bot) eq_(( "#channel", u"Title: Lazarus of Bethany, also known as Saint Lazarus or Lazarus of the Four Days, is the subject of a prominent miracle attributed to Jesus in the Gospel of John, in which Jesus restores him to life four d..." ), module_urltitle.handle_url(bot, None, "#channel", msg, msg))
def test_wiki_fi(): msg = "http://fi.wikipedia.org/wiki/Kimi_Räikkönen" module_urltitle.init(bot) eq_(( "#channel", "Title: Kimi-Matias Räikkönen on suomalainen autourheilija ja Formula 1:n maailmanmestari." ), module_urltitle.handle_url(bot, None, "#channel", msg, msg))
def test_one(): msg = "https://en.wikipedia.org/wiki/Hatfield–McCoy_feud" module_urltitle.init(bot) eq_(( "#channel", u"Title: The Hatfield–McCoy feud involved two families of the West Virginia–Kentucky area along the Tug Fork of the Big Sandy River." ), module_urltitle.handle_url(bot, None, "#channel", msg, msg))
def test_ten(): msg = 'http://en.wikipedia.org/wiki/802.11ac' module_urltitle.init(bot) eq_(( "#channel", u"Title: IEEE 802.11ac is a wireless networking standard in the 802.11 family, developed in the IEEE Standards Association process, providing high-throughput wireless local area networks on the 5\xa0GHz band." ), module_urltitle.handle_url(bot, None, "#channel", msg, msg))
def test_eleven(): msg = 'http://en.wikipedia.org/wiki/Edison_Arantes_do_Nascimento' module_urltitle.init(bot) eq_(( "#channel", u"Title: Edson Arantes do Nascimento, who is better known as Pelé, is a retired Brazilian footballer who is widely regarded to be the best football player of all time." ), module_urltitle.handle_url(bot, None, "#channel", msg, msg))
def test_areena_tv(): regex = u'Title: (.*?) \[%s - %s plays - %s( - exits in \d+ (weeks|days|hours|minutes))?\]' % ( lengh_str_regex, views_str_regex, age_str_regex) msg = "http://areena.yle.fi/tv/1999860" module_urltitle.init(bot) check_re(regex, module_urltitle.handle_url(bot, None, "#channel", msg, msg)[1])
def test_iltasanomat(): msg = "http://www.iltasanomat.fi/viihde/art-1288596309269.html" module_urltitle.init(bot) eq_( ("#channel", "Title: Muistatko Mari Sainion juontaman sarjan, josta sai palkinnoksi isdn-liittymän?"), module_urltitle.handle_url(bot, None, "#channel", msg, msg), )
def test_five(): msg = "http://fi.wikipedia.org/wiki/David_Eddings" module_urltitle.init(bot) eq_(( "#channel", u"Title: David Carroll Eddings oli yhdysvaltalainen kirjailija, joka kirjoitti useita suosittuja fantasiakirjoja." ), module_urltitle.handle_url(bot, None, "#channel", msg, msg))
def test_stackoverflow(): msg = "http://stackoverflow.com/questions/6905508/python-search-html-document-for-capital-letters" module_urltitle.init(bot) eq_(( "#channel", "Title: Python search HTML document for capital letters - 0pts - python/regex/coda/letters/capitalize" ), module_urltitle.handle_url(bot, None, "#channel", msg, msg))
def test_three(): msg = "http://en.wikipedia.org/wiki/Gender_performativity" module_urltitle.init(bot) eq_(( "#channel", u"Title: Gender performativity is a term created by post-structuralist feminist philosopher Judith Butler in her 1990 book Gender Trouble, which has subsequently been used in a variety of academic fields." ), module_urltitle.handle_url(bot, None, "#channel", msg, msg))
def test_wiki_fi(): msg = "http://fi.wikipedia.org/wiki/Kimi_Räikkönen" module_urltitle.init(bot) eq_( ("#channel", "Title: Kimi-Matias Räikkönen on suomalainen autourheilija ja Formula 1:n maailmanmestari."), module_urltitle.handle_url(bot, None, "#channel", msg, msg), )
def test_verkkokauppacom(): msg = "http://www.verkkokauppa.com/fi/product/34214/dkqht/Sony-NEX-3N-mikrojarjestelmakamera-16-50-mm-objektiivi-musta" module_urltitle.init(bot) eq_(( "#channel", "Title: Sony NEX-3N mikrojärjestelmäkamera + 16-50 mm objektiivi, musta. | 369,90 € (heti)" ), module_urltitle.handle_url(bot, None, "#channel", msg, msg))
def test_areena_series(): regex = u'Title: (.*?) \[SERIES - \d+ episodes - latest episode: %s\]' % ( age_str_regex) msg = "http://areena.yle.fi/tv/2129619" module_urltitle.init(bot) check_re(regex, module_urltitle.handle_url(bot, None, "#channel", msg, msg)[1])
def test_areena_tv_exiting(botmock): regex = u"Title: (.*?) \[%s - %s( - exits in %s)?\]" % ( length_str_regex, age_str_regex, age_str_regex, ) msg = "http://areena.yle.fi/1-3093932" check_re(regex, module_urltitle.handle_url(botmock, None, "#channel", msg, msg)[1])
def test_eleven(botmock): msg = "http://en.wikipedia.org/wiki/Edison_Arantes_do_Nascimento" eq_( ( "#channel", u"Title: Edson Arantes do Nascimento, known as Pelé, is a retired Brazilian professional footballer who played as a forward.", ), module_urltitle.handle_url(botmock, None, "#channel", msg, msg), )
def test_five(botmock): msg = "http://fi.wikipedia.org/wiki/David_Eddings" eq_( ( "#channel", u"Title: David Carroll Eddings oli yhdysvaltalainen kirjailija, joka kirjoitti useita suosittuja fantasiakirjoja.", ), module_urltitle.handle_url(botmock, None, "#channel", msg, msg), )
def test_four(botmock): msg = "http://en.wikipedia.org/wiki/Dynamo_(magician)" eq_( ( "#channel", u'Title: Steven Frayne, commonly known by his stage name "Dynamo", is an English magician, best known for his award-winning television show Dynamo: Magician Impossible.', ), module_urltitle.handle_url(botmock, None, "#channel", msg, msg), )
def test_eight(botmock): msg = "https://en.wikipedia.org/wiki/Byzantine_art#Periods" eq_( ( "#channel", u"Title: Byzantine art is the name for the artistic products of the Eastern Roman Empire, as well as the nations and states that inherited culturally from the empire.", ), module_urltitle.handle_url(botmock, None, "#channel", msg, msg), )
def test_seven(botmock): msg = "http://en.wikipedia.org/wiki/Ramon_Llull" eq_( ( "#channel", u"Title: Ramon Llull, T.O.S.F. was a philosopher, logician, Franciscan tertiary and Majorcan writer.", ), module_urltitle.handle_url(botmock, None, "#channel", msg, msg), )
def test_areena_not_available(botmock): regex = u"Title: (.*?) \[%s - %s - not available\]" % ( length_str_regex, age_str_regex, ) msg = "http://areena.yle.fi/1-2372901" check_re( regex, module_urltitle.handle_url(botmock, None, "#channel", msg, msg)[1])
def test_youtube(): regex = "Title: (.*?) by (.*?) \[%s - %s views - %s( - age restricted)?\]" % ( lengh_str_regex, views_str_regex, age_str_regex, ) msg = "http://www.youtube.com/watch?v=awsolTK175c" module_urltitle.init(bot) check_re(regex, module_urltitle.handle_url(bot, None, "#channel", msg, msg)[1])
def test_twelve(botmock): msg = "http://en.wikipedia.org/wiki/Mr._Bean" eq_( ( "#channel", u"Title: Mr. Bean is a British sitcom created by Rowan Atkinson and Richard Curtis, and starring Atkinson in the title role.", ), module_urltitle.handle_url(botmock, None, "#channel", msg, msg), )
def test_ten(botmock): msg = "http://en.wikipedia.org/wiki/802.11ac" eq_( ( "#channel", u"Title: IEEE 802.11ac is a wireless networking standard in the 802.11 family, developed in the IEEE Standards Association process, providing high-throughput wireless local area networks on the 5\xa0GHz band.", ), module_urltitle.handle_url(botmock, None, "#channel", msg, msg), )
def test_eleven(botmock): msg = "http://en.wikipedia.org/wiki/Edison_Arantes_do_Nascimento" eq_( ( "#channel", u"Title: Edson Arantes do Nascimento, known as Pel\xe9, is a Brazilian former professional footballer who played as a forward.", ), module_urltitle.handle_url(botmock, None, "#channel", msg, msg), )
def test_seven(botmock): msg = "http://en.wikipedia.org/wiki/Ramon_Llull" eq_( ( "#channel", u"Title: Ramon Llull was a mathematician, polymath, philosopher, logician, writer and mystic from the Kingdom of Majorca.", ), module_urltitle.handle_url(botmock, None, "#channel", msg, msg), )
def test_eight(botmock): msg = "https://en.wikipedia.org/wiki/Byzantine_art#Periods" eq_( ( "#channel", u"Title: Byzantine art comprises the body of Christian Greek artistic products of the Eastern Roman Empire, as well as the nations and states that inherited culturally from the empire.", ), module_urltitle.handle_url(botmock, None, "#channel", msg, msg), )
def test_nine(botmock): msg = u"http://fi.wikipedia.org/wiki/Kimi_Räikkönen" eq_( ( "#channel", u"Title: Kimi-Matias Räikkönen on suomalainen autourheilija ja Formula 1 -sarjan maailmanmestari.", ), module_urltitle.handle_url(botmock, None, "#channel", msg, msg), )
def test_ten(botmock): msg = "http://en.wikipedia.org/wiki/802.11ac" eq_( ( "#channel", u"Title: IEEE 802.11ac-2013 or 802.11ac is a wireless networking standard in the 802.11 set of protocols, providing high-throughput wireless local area networks on the 5\xa0GHz band.", ), module_urltitle.handle_url(botmock, None, "#channel", msg, msg), )
def test_four(botmock): msg = "http://en.wikipedia.org/wiki/Dynamo_(magician)" eq_( ( "#channel", u'Title: Steven Frayne, better known by his stage name Dynamo, is a British magician born in Bradford, West Yorkshire.', ), module_urltitle.handle_url(botmock, None, "#channel", msg, msg), )
def test_twelve(botmock): msg = "http://en.wikipedia.org/wiki/Mr._Bean" eq_( ( "#channel", u"Title: Mr. Bean is a British sitcom created by Rowan Atkinson and Richard Curtis, produced by Tiger Aspect and starring Atkinson as the title character.", ), module_urltitle.handle_url(botmock, None, "#channel", msg, msg), )
def test_three(): msg = "http://en.wikipedia.org/wiki/Gender_performativity" module_urltitle.init(bot) eq_( ( "#channel", u"Title: Gender performativity is a term created by post-structuralist feminist philosopher Judith Butler in her 1990 book Gender Trouble, which has subsequently been used in a variety of academic fields.", ), module_urltitle.handle_url(bot, None, "#channel", msg, msg), )
def test_one(): msg = "https://en.wikipedia.org/wiki/Hatfield–McCoy_feud" module_urltitle.init(bot) eq_( ( "#channel", u"Title: The Hatfield–McCoy feud involved two families of the West Virginia–Kentucky area along the Tug Fork of the Big Sandy River.", ), module_urltitle.handle_url(bot, None, "#channel", msg, msg), )
def test_eight(): msg = "http://en.wikipedia.org/wiki/Lazarus_of_Bethany#In_culture" module_urltitle.init(bot) eq_( ( "#channel", u"Title: Lazarus of Bethany, also known as Saint Lazarus or Lazarus of the Four Days, is the subject of a prominent miracle attributed to Jesus in the Gospel of John, in which Jesus restores him to life four d...", ), module_urltitle.handle_url(bot, None, "#channel", msg, msg), )
def test_stackoverflow(): msg = "http://stackoverflow.com/questions/6905508/python-search-html-document-for-capital-letters" module_urltitle.init(bot) eq_( ( "#channel", "Title: Python search HTML document for capital letters - 0pts - python/regex/coda/letters/capitalize", ), module_urltitle.handle_url(bot, None, "#channel", msg, msg), )
def test_vimeo(): regex = "Title: (.*?) by (.*?) \[%s - %s likes - %s views - %s]" % ( lengh_str_regex, views_str_regex, views_str_regex, age_str_regex, ) msg = "http://vimeo.com/29996808" module_urltitle.init(bot) check_re(regex, module_urltitle.handle_url(bot, None, "#channel", msg, msg)[1])
def test_four(): msg = "http://en.wikipedia.org/wiki/Dynamo_(magician)" module_urltitle.init(bot) eq_( ( "#channel", u"Title: Dynamo is an English magician, best known for his fly on the wall documentary show Dynamo: Magician Impossible.", ), module_urltitle.handle_url(bot, None, "#channel", msg, msg), )
def test_areena_tv_exiting_in_far_far_future(botmock): from datetime import datetime if datetime.utcnow() < datetime(2098, 1, 1): regex = u'Title: Kummeli - 5x03 \[%s - %s\]' % (length_str_regex, age_str_regex) else: regex = u'Title: Kummeli - 5x03 \[%s - %s( - exits in %s)?\]' % (length_str_regex, age_str_regex, age_str_regex) msg = "http://areena.yle.fi/1-1823488" check_re(regex, module_urltitle.handle_url(botmock, None, "#channel", msg, msg)[1])
def test_verkkokauppacom(): msg = "http://www.verkkokauppa.com/fi/product/34214/dkqht/Sony-NEX-3N-mikrojarjestelmakamera-16-50-mm-objektiivi-musta" module_urltitle.init(bot) eq_(("#channel", u"Title: Sony NEX-3N mikrojärjestelmäkamera + 16-50 mm objektiivi, musta. | 369,90 € (heti)"), module_urltitle.handle_url(bot, None, "#channel", msg, msg))
def test_alko(): regex = u'Title: Sandels IV A tölkki \[\d\.\d\de, \d\.\d\dl, \d\.\d\de/l, oluet, 5\.30\%\]' msg = 'http://www.alko.fi/tuotteet/798684/' module_urltitle.init(bot) check_re(regex, module_urltitle.handle_url(bot, None, "#channel", msg, msg)[1])
def test_dx(): regex = u'Title: Wireless Bluetooth Audio Music Receiver Adapter - Black \[\d+\.\d+e - \[\** *\] - \d+ reviews\]' msg = 'http://dx.com/p/wireless-bluetooth-audio-music-receiver-adapter-black-151659' module_urltitle.init(bot) check_re(regex, module_urltitle.handle_url(bot, None, "#channel", msg, msg)[1])