# Path: feeds/tasks.py
# def poll_feed(feed):
# def poll_all_feeds():
# 
# Path: feeds/models.py
# class Feed(models.Model):
#     title = models.CharField(max_length=200)
#     link = models.CharField(max_length=1000)
# 
#     def __unicode__(self):
#         return self.title
# 
# class Entry(models.Model):
#     title = models.CharField(max_length=200)
#     link = models.CharField(max_length=1000)
#     feed = models.ForeignKey(to=Feed)
#     published = models.DateTimeField()
# 
#     def __unicode__(self):
#         return u'{}: {}'.format(self.feed, self.title)
# 
# Path: profiles/models.py
# class UserEntryDetail(models.Model):
#     profile = models.ForeignKey(to=UserProfile)
#     entry = models.ForeignKey(to=Entry)
#     read = models.BooleanField()
# 
#     def __unicode__(self):
#         return u'User: {}, Entry: {}, Read: {}'.format(
#                                                 self.profile.user.username,
#                                                 self.entry,
#                                                 self.read)
# 
# class UserProfile(models.Model):
#     """A user profile."""
#     user = models.ForeignKey(User)
#     feeds = models.ManyToManyField(to=Feed, through='profiles.Subscription')
#     entries = models.ManyToManyField(to=Entry,
#                                      through='profiles.UserEntryDetail')
#     next_slug = RandomSlugField(slug_length=10)
# 
#     def __unicode__(self):
#         return u"{}'s profile".format(self.user.username)
# 
#     def subscribe(self, feed):
#         Subscription.objects.create(profile=self, feed=feed)
# 
#     def unsubscribe(self, feed):
#         Subscription.objects.get(profile=self, feed=feed).delete()
#         self._get_entries(feed).delete()
# 
#     def mark_read(self, feed):
#         entries = self._get_entries(feed)
#         for entry in entries:
#             entry.read = True
#             entry.save()
# 
#     def mark_unread(self, feed):
#         entries = self._get_entries(feed)
#         for entry in entries:
#             entry.read = False
#             entry.save()
# 
#     def unread_entries(self, feed):
#         return self._get_entries(feed).filter(read=False).count()
# 
#     def _get_entries(self, feed):
#         return UserEntryDetail.objects.filter(profile=self, entry__feed=feed)
# 
# class Subscription(models.Model):
#     profile = models.ForeignKey(to=UserProfile)
#     feed = models.ForeignKey(to=Feed)
# 
#     def unread_entries_num(self):
#         unread_entries = UserEntryDetail.objects.filter(read=False,
#                                                         profile=self.profile,
#                                                         entry__feed=self.feed)
#         return unread_entries.count()


import mock
import datetime
from collections import namedtuple
from django.test import TestCase
from django.contrib.auth.models import User
from feeds import tasks
from feeds.models import Feed, Entry
from profiles.models import UserEntryDetail, UserProfile, Subscription
"""Feed-related tests."""



FeedParserEntry = namedtuple('FeedParserEntry', 'link title published_parsed')


class PollFeedTest(TestCase):
    def setUp(self):

# Path: feeds/tasks.py
# def poll_feed(feed):
# def poll_all_feeds():
# 
# Path: feeds/models.py
# class Feed(models.Model):
#     title = models.CharField(max_length=200)
#     link = models.CharField(max_length=1000)
# 
#     def __unicode__(self):
#         return self.title
# 
# class Entry(models.Model):
#     title = models.CharField(max_length=200)
#     link = models.CharField(max_length=1000)
#     feed = models.ForeignKey(to=Feed)
#     published = models.DateTimeField()
# 
#     def __unicode__(self):
#         return u'{}: {}'.format(self.feed, self.title)
# 
# Path: profiles/models.py
# class UserEntryDetail(models.Model):
#     profile = models.ForeignKey(to=UserProfile)
#     entry = models.ForeignKey(to=Entry)
#     read = models.BooleanField()
# 
#     def __unicode__(self):
#         return u'User: {}, Entry: {}, Read: {}'.format(
#                                                 self.profile.user.username,
#                                                 self.entry,
#                                                 self.read)
# 
# class UserProfile(models.Model):
#     """A user profile."""
#     user = models.ForeignKey(User)
#     feeds = models.ManyToManyField(to=Feed, through='profiles.Subscription')
#     entries = models.ManyToManyField(to=Entry,
#                                      through='profiles.UserEntryDetail')
#     next_slug = RandomSlugField(slug_length=10)
# 
#     def __unicode__(self):
#         return u"{}'s profile".format(self.user.username)
# 
#     def subscribe(self, feed):
#         Subscription.objects.create(profile=self, feed=feed)
# 
#     def unsubscribe(self, feed):
#         Subscription.objects.get(profile=self, feed=feed).delete()
#         self._get_entries(feed).delete()
# 
#     def mark_read(self, feed):
#         entries = self._get_entries(feed)
#         for entry in entries:
#             entry.read = True
#             entry.save()
# 
#     def mark_unread(self, feed):
#         entries = self._get_entries(feed)
#         for entry in entries:
#             entry.read = False
#             entry.save()
# 
#     def unread_entries(self, feed):
#         return self._get_entries(feed).filter(read=False).count()
# 
#     def _get_entries(self, feed):
#         return UserEntryDetail.objects.filter(profile=self, entry__feed=feed)
# 
# class Subscription(models.Model):
#     profile = models.ForeignKey(to=UserProfile)
#     feed = models.ForeignKey(to=Feed)
# 
#     def unread_entries_num(self):
#         unread_entries = UserEntryDetail.objects.filter(read=False,
#                                                         profile=self.profile,
#                                                         entry__feed=self.feed)
#         return unread_entries.count()


# Path: feeds/tests.py
import mock
import datetime
from collections import namedtuple
from django.test import TestCase
from django.contrib.auth.models import User
from feeds import tasks
from feeds.models import Feed, Entry
from profiles.models import UserEntryDetail, UserProfile, Subscription

"""Feed-related tests."""



FeedParserEntry = namedtuple('FeedParserEntry', 'link title published_parsed')


class PollFeedTest(TestCase):
    def setUp(self):

        self.feed = Feed(link="http://link.to/rss.xml",