def post(self, request, *args, **kwargs): """ Handles Feed update from hub server. Updates when necessary and ignores bad requests. """ feed = feedparser.parse(request.body) feed_links = models.get_all_feed_links(feed.feed.links) subscription = models.HubbubSubscription.get_by_url_list(feed_links) if subscription: models.sync_blog_feed(feedparser.parse(request.body)) else: feed_url = models.get_feed_link(feed.feed.links, 'self') logging.warn("Discarding unknown feed: %s", feed_url) return http.HttpResponse(status=204)
def test_get_feed_link_returns_none_when_param_not_found(self): links = [{'href': "link/two", 'rel': 'edit'}] link = models.get_feed_link(links, 'self') self.assertEqual(None, link)
def test_get_feed_link_returns_link_for_param(self): links = [{'href': "link/one", 'rel': 'self'}, {'href': "link/two", 'rel': 'edit'}] link = models.get_feed_link(links, 'self') self.assertEqual('link/one', link)