# Path: planet/models.py
# class Post(models.Model):
#     """
#     A feed contains a collection of posts. This model stores them.
#     """
#     feed = models.ForeignKey("planet.Feed", null=False, blank=False)
#     title = models.CharField(_("Title"), max_length=255, db_index=True)
#     authors = models.ManyToManyField("planet.Author", through=PostAuthorData)
#     url = models.URLField(_("Url"), max_length=1000, db_index=True)
#     guid = models.CharField(_("Guid"), max_length=32, db_index=True)
#     content = models.TextField(_("Content"))
#     comments_url = models.URLField(_("Comments URL"), blank=True, null=True)
# 
#     date_modified = models.DateTimeField(_("Date modified"), null=True,
#         blank=True, db_index=True)
#     date_created = models.DateTimeField(_("Date created"), auto_now_add=True)
# 
#     site_objects = PostManager()
#     objects = models.Manager()
# 
#     class Meta:
#         verbose_name = _("Post")
#         verbose_name_plural = _("Posts")
#         ordering = ('-date_created', '-date_modified')
#         unique_together = (('feed', 'guid'),)
# 
#     def __str__(self):
#         return "{} [{}]".format(self.title, self.feed.title)
# 
#     @models.permalink
#     def get_absolute_url(self):
#         return ('planet.views.post_detail', [str(self.id), self.get_slug()])
# 
#     def get_slug(self):
#         return slugify(self.title) or "no-title"
# 
# Path: planet/tests/factories.py
# class BlogFactory(factory.DjangoModelFactory):
#     class Meta:
#         model = Blog
# 
#     title = factory.Sequence(lambda n: u'blog-{}'.format(n))
#     url = factory.LazyAttribute(lambda obj: u'http://{}.blogspot.com/'.format(obj.title))
#     owner = None
# 
# class FeedFactory(factory.DjangoModelFactory):
#     class Meta:
#         model = Feed
# 
#     title = factory.Sequence(lambda n: u'Feed-{}'.format(n))
#     blog = factory.SubFactory(BlogFactory)
#     url = factory.LazyAttribute(lambda obj: '{}feed-{}.rss'.format(obj.blog.url, obj.title))
#     generator = factory.SubFactory(GeneratorFactory)
#     language = "en"
#     site = factory.SubFactory(SiteFactory)
# 
# class PostFactory(factory.DjangoModelFactory):
#     class Meta:
#         model = Post
# 
#     title = factory.Sequence(lambda n: u'Post Title #{}'.format(n))
#     feed = factory.SubFactory(FeedFactory)
#     url = factory.LazyAttribute(lambda obj: u'post-{}.html'.format(obj.feed.blog.url))
#     guid = factory.Sequence(lambda n: u'GUID-{}'.format(n))
#     content = FuzzyText(length=200)
# 
#     @factory.post_generation
#     def authors(self, create, extracted, **kwargs):
#         if not create:
#             # Simple build, do nothing.
#             return
# 
#         if extracted:
#             # A list of groups were passed in, use them
#             for author in extracted:
#                 PostAuthorDataFactory.create(post=self, author=author)
# 
# class AuthorFactory(factory.DjangoModelFactory):
#     class Meta:
#         model = Author
# 
#     name = factory.Sequence(lambda n: u'Author #{}'.format(n))
#     email = factory.LazyAttribute(lambda obj: u'{}@gmail.com'.format(obj.name))


from mock import patch
from django.contrib.sites.models import Site
from django.test import TestCase
from planet.models import Post
from planet.tests.factories import (
    BlogFactory, FeedFactory, PostFactory, AuthorFactory
)
        self.assertEqual(response.status_code, 404)

    def tearDown(self):
        self.post.delete()
        self.feed.delete()


class MicroformatsViewsTest(TestCase):

    def setUp(self):
        self.site = Site.objects.get_current()
        self.feed = FeedFactory.create(title="Feed-1", site=self.site)

    def test_opml(self):
        response = self.client.get("/opml/")
        self.assertEqual(response.status_code, 200)

    def test_foaf(self):
        response = self.client.get("/foaf/")
        self.assertEqual(response.status_code, 200)

    def tearDown(self):
        self.feed.delete()


class FeedsViewsTest(TestCase):

    def setUp(self):
        self.site = Site.objects.get_current()
        self.feed = FeedFactory.create(title="Feed-1", site=self.site)

# Path: planet/models.py
# class Post(models.Model):
#     """
#     A feed contains a collection of posts. This model stores them.
#     """
#     feed = models.ForeignKey("planet.Feed", null=False, blank=False)
#     title = models.CharField(_("Title"), max_length=255, db_index=True)
#     authors = models.ManyToManyField("planet.Author", through=PostAuthorData)
#     url = models.URLField(_("Url"), max_length=1000, db_index=True)
#     guid = models.CharField(_("Guid"), max_length=32, db_index=True)
#     content = models.TextField(_("Content"))
#     comments_url = models.URLField(_("Comments URL"), blank=True, null=True)
# 
#     date_modified = models.DateTimeField(_("Date modified"), null=True,
#         blank=True, db_index=True)
#     date_created = models.DateTimeField(_("Date created"), auto_now_add=True)
# 
#     site_objects = PostManager()
#     objects = models.Manager()
# 
#     class Meta:
#         verbose_name = _("Post")
#         verbose_name_plural = _("Posts")
#         ordering = ('-date_created', '-date_modified')
#         unique_together = (('feed', 'guid'),)
# 
#     def __str__(self):
#         return "{} [{}]".format(self.title, self.feed.title)
# 
#     @models.permalink
#     def get_absolute_url(self):
#         return ('planet.views.post_detail', [str(self.id), self.get_slug()])
# 
#     def get_slug(self):
#         return slugify(self.title) or "no-title"
# 
# Path: planet/tests/factories.py
# class BlogFactory(factory.DjangoModelFactory):
#     class Meta:
#         model = Blog
# 
#     title = factory.Sequence(lambda n: u'blog-{}'.format(n))
#     url = factory.LazyAttribute(lambda obj: u'http://{}.blogspot.com/'.format(obj.title))
#     owner = None
# 
# class FeedFactory(factory.DjangoModelFactory):
#     class Meta:
#         model = Feed
# 
#     title = factory.Sequence(lambda n: u'Feed-{}'.format(n))
#     blog = factory.SubFactory(BlogFactory)
#     url = factory.LazyAttribute(lambda obj: '{}feed-{}.rss'.format(obj.blog.url, obj.title))
#     generator = factory.SubFactory(GeneratorFactory)
#     language = "en"
#     site = factory.SubFactory(SiteFactory)
# 
# class PostFactory(factory.DjangoModelFactory):
#     class Meta:
#         model = Post
# 
#     title = factory.Sequence(lambda n: u'Post Title #{}'.format(n))
#     feed = factory.SubFactory(FeedFactory)
#     url = factory.LazyAttribute(lambda obj: u'post-{}.html'.format(obj.feed.blog.url))
#     guid = factory.Sequence(lambda n: u'GUID-{}'.format(n))
#     content = FuzzyText(length=200)
# 
#     @factory.post_generation
#     def authors(self, create, extracted, **kwargs):
#         if not create:
#             # Simple build, do nothing.
#             return
# 
#         if extracted:
#             # A list of groups were passed in, use them
#             for author in extracted:
#                 PostAuthorDataFactory.create(post=self, author=author)
# 
# class AuthorFactory(factory.DjangoModelFactory):
#     class Meta:
#         model = Author
# 
#     name = factory.Sequence(lambda n: u'Author #{}'.format(n))
#     email = factory.LazyAttribute(lambda obj: u'{}@gmail.com'.format(obj.name))


# Path: planet/tests/test_views.py
from mock import patch
from django.contrib.sites.models import Site
from django.test import TestCase
from planet.models import Post
from planet.tests.factories import (
    BlogFactory, FeedFactory, PostFactory, AuthorFactory
)

        self.assertEqual(response.status_code, 404)

    def tearDown(self):
        self.post.delete()
        self.feed.delete()


class MicroformatsViewsTest(TestCase):

    def setUp(self):
        self.site = Site.objects.get_current()
        self.feed = FeedFactory.create(title="Feed-1", site=self.site)

    def test_opml(self):
        response = self.client.get("/opml/")
        self.assertEqual(response.status_code, 200)

    def test_foaf(self):
        response = self.client.get("/foaf/")
        self.assertEqual(response.status_code, 200)

    def tearDown(self):
        self.feed.delete()


class FeedsViewsTest(TestCase):

    def setUp(self):
        self.site = Site.objects.get_current()
        self.feed = FeedFactory.create(title="Feed-1", site=self.site)

        self.author = AuthorFactory.create(name="Author-1")