def test_simple_self_post(self): post = Link(is_self=True, selftext=''' Some text here. https://example.com https://reddit.com''') url = _get_scrape_url(post) self.assertEqual(url, 'https://example.com')
def test_imgur_link(self): post = Link(is_self=True, selftext=''' Some text here. https://example.com https://imgur.com''') url = _get_scrape_url(post) self.assertEqual(url, 'https://imgur.com')
def test_image_link(self): post = Link(is_self=True, selftext=''' Some text here. https://example.com https://reddit.com/a.jpg''') url = _get_scrape_url(post) self.assertEqual(url, 'https://reddit.com/a.jpg') post = Link(is_self=True, selftext=''' Some text here. https://example.com https://reddit.com/a.PNG''') url = _get_scrape_url(post) self.assertEqual(url, 'https://reddit.com/a.PNG') post = Link(is_self=True, selftext=''' Some text here. https://example.com https://reddit.com/a.jpg/b''') url = _get_scrape_url(post) self.assertEqual(url, 'https://example.com')
def test_link_post(self): post = Link(url='https://example.com') url = _get_scrape_url(post) self.assertEqual(url, 'https://example.com')
if not good_preview_object(link.preview_object): continue if not link.preview_object == preview_object: print " aborting - preview objects don't match" print ' first: %s' % preview_object print ' ours: %s' % link.preview_object continue link.preview_object['url'] = url link._commit() # Guess at the key that'll contain the (now-incorrect) cache of the # preview object so we can delete it and not end up inserting old info # into new Links. # # These parameters are what's used in most of the code; the only place # they're overridden is for promoted links, where they could be # anything. We'll just have to deal with those as they come up. image_url = _get_scrape_url(link) cache_key = MediaByURL._rowkey(image_url, autoplay=False, maxwidth=600) print ' deleting cache with key %s' % cache_key cache = MediaByURL(_id=cache_key) cache._committed = True try: cache._destroy() except pycassa.cassandra.ttypes.InvalidRequestException as e: print ' skipping cache deletion (%s)' % e.why continue # Delete *after* we've updated all the Links so they'll continue to work # while we're in the migration process. k.delete()
def test_link_post(self, Link): post = Link() post.url = 'https://example.com' post.is_self = False url = _get_scrape_url(post) self.assertEqual(url, 'https://example.com')