def test_update_all_feed(self):
        """
        Test update_all_feeds
        """
        with patched_feedparser(iwatch_old):
            call_command("add_feed", "http://www.iwatachnews.or/rss/")
            post_count = Post.objects.count()
            feed_count = Feed.objects.count()

            self.assertEqual(post_count, 16)
            self.assertEqual(feed_count, 1)

        with patched_feedparser(iwatch):
            call_command("update_all_feeds")
            post_count = Post.objects.count()
            self.assertEqual(post_count, 18)
    def test_feed_parsing(self):
        with patched_feedparser('torvalds-family.xml'):
            call_command('add_feed', 'http://torvalds-family.blogspot.com/feeds/posts/default')
            post_count = Post.objects.count()
            feed_count = Feed.objects.count()

            self.assertEqual(post_count, 25)
            self.assertEqual(feed_count, 1)

            p = Post.objects.get(pk=1)

            self.assertEqual(p.title, 'Glamorous pictures?')
            self.assertEqual(p.content, """<a href="http://2.bp.blogspot.com/-gx9KQhITQCg/TW5iPNYRi5I/AAAAAAAAABA/ONZ1OwliW7g/s1600/1994-May-NewOrleans-Linus-Linux-MediumRes.jpeg"><img alt="" border="0" id="BLOGGER_PHOTO_ID_5579505001787657106" src="http://2.bp.blogspot.com/-gx9KQhITQCg/TW5iPNYRi5I/AAAAAAAAABA/ONZ1OwliW7g/s320/1994-May-NewOrleans-Linus-Linux-MediumRes.jpeg" style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; cursor: hand; width: 320px; height: 227px;" /></a>The event last weekend was a "no cameras" event, and while we'll have pictures, I don't have them yet. <div><br /></div><div>And I think I'll keep them private when we get them - no need to embarrass the beautiful people any more than we already did.</div><div><br /></div><div>So to make up for that, here's a glamorous shot from about seventeen years ago that maddog (on the left) found the other day. It's from DECUS, New Orleans, 1994.</div><div><br /></div><div>As you can tell, I knew how to party back then too. I'm the handsome young man on the right, in case you couldn't guess.</div><div><br /></div><div>They called me "The Stud".</div><div class="blogger-post-footer"><img alt="" height="1" src="https://blogger.googleusercontent.com/tracker/4999557720148026925-51969794830797005?l=torvalds-family.blogspot.com" width="1" /></div>""") # I'm sorry for this :)
            self.assertEqual(p.url, 'http://torvalds-family.blogspot.com/2011/03/glamorous-pictures.html')
            self.assertEqual(p.url, p.guid)
            self.assertEqual(p.hidden, False)

            self.assertEqual(p.feed_id, 1)
            self.assertEqual(p.feed.url, 'http://torvalds-family.blogspot.com/feeds/posts/default')

            self.assertEqual(p.enclosure_set.all()[0].link, 'http://2.bp.blogspot.com/-gx9KQhITQCg/TW5iPNYRi5I/AAAAAAAAABA/ONZ1OwliW7g/s72-c/1994-May-NewOrleans-Linus-Linux-MediumRes.jpeg')
            self.assertEqual(p.postauthordata_set.all()[0].author.name, 'Linus')

            self.assertEqual(p.postlink_set.count(), 5)
            self.assertEqual(p.postlink_set.all()[0].link, u'http://www.blogger.com/feeds/4999557720148026925/posts/default/51969794830797005')

            tags = [x.name for x in p.tags]
            self.assertTrue('decus' in tags)
            self.assertTrue('stud' in tags)
            self.assertEqual(len(tags), 2)

            # test dates
            post_age = datetime.now() - p.date_created
            self.assertLess(post_age.seconds, 60)
            self.assertEqual(str(p.date_modified), '2011-03-02 15:43:09')

            # test get_(next|prev)_by_date_created
            self.assertEqual(p.get_next_by_date_created().url, 'http://torvalds-family.blogspot.com/2011/02/pearls-before-swine.html')

            exception_name = ''
            try:
                p.get_previous_by_date_created()
            except Exception as e:
                exception_name = e.__class__.__name__
            self.assertEqual(exception_name, 'DoesNotExist')