def test_constructor(self): wrangler = lounge_wrangler(forum_id=self.phillies_forum_id, cookie=self.my_cookie) self.assertEqual(wrangler.main_url, self.phillies_url) self.assertEqual(wrangler.cookie, self.my_cookie) wrangler = lounge_wrangler(cookie=self.my_cookie) self.assertEqual(wrangler.cookie, self.my_cookie) self.assertEqual(wrangler.main_url, "http://www.baseballthinkfactory.org/files/forums/viewforum/79/")
def test_latest_url_from_file(self): wrangler = lounge_wrangler(forum_id=self.phillies_forum_id, cookie=self.my_cookie) self.assertEqual( wrangler.latest_url_from_file(open("testdata/phillies.html")), "http://www.baseballthinkfactory.org/files/forums/viewthread/1557/", ) self.assertEqual( wrangler.latest_url_from_file(open("testdata/lounge.html")), "http://www.baseballthinkfactory.org/files/forums/viewthread/2058/P1000/", ) self.assertEqual( wrangler.latest_url_from_file(open("testdata/forum_after_upgrade.html")), "http://www.baseballthinkfactory.org/files/forums/viewthread/3096/P150/", )
def test_line_has_last_forum_url(self): wrangler = lounge_wrangler(forum_id=self.phillies_forum_id, cookie=self.my_cookie) self.assertEqual( wrangler.line_has_last_forum_url( "href='http://www.baseballthinkfactory.org/files/forums/viewthread/2058/P1000/'>21</a>)</span>" ), True, ) self.assertFalse( wrangler.line_has_last_forum_url( "href='http://www.baseballthinkfactory.org/files/forums/viewthread/2114/P1000/'>21</a>)</span>" ) ) self.assertFalse( wrangler.line_has_last_forum_url( "href='http://www.baseballthinkfactory.org/files/forums/viewthread/2120/P1000/'>21</a>)</span>" ) )
#!/usr/bin/python from lounge_wrangler import lounge_wrangler from lounge_wrangler_secrets import username, password wrangler = lounge_wrangler(forum_id='90', username=username, password=password, cache_seconds=300, cache_filename="writable/cached_url.txt") url = wrangler.latest_lounge_url_caching() print "Location: " + url + "\n\n";
#!/usr/bin/python from lounge_wrangler import lounge_wrangler from lounge_wrangler_secrets import my_cookie wrangler = lounge_wrangler(forum_id='90', cookie=my_cookie, cache_filename='/tmp/whatever.txt') wrangler.post_to_forum( topic_id=wrangler.latest_lounge_topic_id_caching(), forum_id=90, text="Programmatic Lounge posting gets easier every day.")
def test_latest_topic_id_from_file(self): wrangler = lounge_wrangler(forum_id=self.phillies_forum_id, cookie=self.my_cookie) self.assertEqual(wrangler.latest_topic_id_from_file(open("testdata/phillies.html")), "1557") self.assertEqual(wrangler.latest_topic_id_from_file(open("testdata/lounge.html")), "2058")