def test_force(): class PermanentlyRedirectedFeed(_BasePermanentlyRedirectedFeed): def pass1(feed): # feed url has changed assert feed.url == u'http://new.org/feeds/rss' feedev.testcustom(COMMON_FEEDS + [PermanentlyRedirectedFeed], addins=[update_redirects(force=True)])
def test_ignore(): class PermanentlyRedirectedFeed(_BasePermanentlyRedirectedFeed): def pass1(feed): # feed url has *not* changed assert feed.url == u'http://myolddomain.com/feed.xml' feedev.testcustom(COMMON_FEEDS + [PermanentlyRedirectedFeed], addins=[update_redirects(ignore=True)])
def test_delete_other(): class PermanentlyRedirectedFeed(_BasePermanentlyRedirectedFeed): def pass1(feed): # url has changed assert feed.url == u'http://new.org/feeds/rss' # no other feed with that url exists assert db.store.find(models.Feed, models.Feed.url == u'http://new.org/feeds/rss').count() == 1 feedev.testcustom(COMMON_FEEDS + [PermanentlyRedirectedFeed], addins=[update_redirects(delete="other")])
def test_delete_self(): class PermanentlyRedirectedFeed(_BasePermanentlyRedirectedFeed): def pass1(feed): # current feed object does no longer exist assert db.store.find(models.Feed, models.Feed.id == feed.id).count() == 0 # there were two other feeds with the same url that we are # redirecting to, they both still exist (we have only deleted # ourselfs). assert db.store.find(models.Feed, models.Feed.url == u'http://new.org/feeds/rss').count() == 2 feedev.testcustom(COMMON_FEEDS + [PermanentlyRedirectedFeed], addins=[update_redirects(delete="self")])
def test_image(image): class TestFeed(feedev.Feed): content = """ <rss><channel> <image><url>"""+image.url+"""</url></image> </channel></rss> """ def pass1(feed): # no exception raised pass feedev.testcustom([TestFeed, image], addins=ADDINS)
def test_basic(): """ Only the explicitly specified feeds are used. """ class LocalFeed1(GlobalFeed): pass class LocalFeed2(GlobalFeed): pass testrunner = feedev.testcustom([LocalFeed1]) assert called == 1 # we get a reference to the testrunner object back assert hasattr(testrunner, "run") # it is possible to request the test not automatically run feedev.testcustom([LocalFeed1], run=False) assert called == 1 # ...so this is still 1
def _test_image(image): """We'd like to use our fake HTTP handler to test images, but it is only enabled by the test framework while the tests are running. There is currently no real good way to have the handler active and serving some files files without going through the motions of using feeds with pass-level test functions. To make things in this particular test module easier, this utility function creates a dummy feed with one pass to give to the test framework, and then calls a ``test`` function on the ``image`` object you passed in, with a ``RemoteImage`` instance hooked up to the url of ``image`` passed in, for convenience. """ class FakeFeed(feedev.Feed): def pass1(feed): # RemoteImage exposes a unicode interface, but expects # the url given be unicode as well. image.test(RemoteImage(unicode(image.url))) feedev.testcustom([image, FakeFeed])
def _get_file(File): return test.testcustom([File], run=False).get_file(File.url)
def test_no_passes(): try: feedev.testcustom([]) except Exception, e: assert "nothing to test" in str(e)