def test_create_empty_weekly_digest_entry(self): "No digest entry will be created if there are no models.Entry objects for the given period" compobj = dh.create_digest_entry(self.digestobj, today=self.start_dt - timedelta(days=1)) self.assertEqual(compobj, None) compobj2 = dh.create_digest_entry(self.digestobj, today=self.end_dt + timedelta(days=7)) self.assertEqual(compobj2, None)
def test_create_empty_digest_entry(self): "No digest entry will be created if there are no models.Entry objects for the given period." # one day before period starts compobj = dh.create_digest_entry(self.digestobj, today=self.start_dt - timedelta(days=1)) self.assertEqual(compobj, None) # one day after period ends compobj = dh.create_digest_entry(self.digestobj, today=self.end_dt + timedelta(days=1)) self.assertEqual(compobj, None)
def test_create_digest_entry_force_date_entries(self): "Ensure a digest entry created in the past correctly finds and associates entries from the same day." two_days_ago = self.today - timedelta(days=2) compobj = dh.create_digest_entry(self.digestobj, today=two_days_ago) # this type of test will only work with daily digests ... obviously :P for c in compobj.entries.all(): self.assertTrue(c.last_updated >= two_days_ago) self.assertTrue(c.last_updated <= self.today)
def setUp(self): self.period = 7 today_sat = datetime.now() + rd.relativedelta(weekday=rd.SA) cbit = self.custom_feed_url(self.period, today_sat - timedelta(days=self.period), today_sat).lstrip('/') logic.pull_feed("http://localhost:8000/endtimes/%s" % cbit, create_entries=True) self.feedobj = models.Feed.objects.get(pk=1) self.digestobj, created = dh.get_create_digest_feed( self.get_user(), self.feedobj, 'weekly', 'sat') self.compobj = dh.create_digest_entry(self.digestobj) self.assertTrue(isinstance(self.compobj, models.DigestEntry)) self.assertTrue(self.compobj.entries.all().count() > 0)
def test_create_weekly_digest_entry_duplicate(self): "The creation of a weekly digest entry will fail to create a duplicate if one already exists" compobj = dh.create_digest_entry(self.digestobj, today=self.today) compobj2 = dh.create_digest_entry(self.digestobj, today=self.today) self.assertEqual(compobj.id, compobj2.id)
def test_create_weekly_digest_entry_force_date(self): "A weekly digest entry can be created at any time and not just on the week borders" three_days_ago = self.today - timedelta(days=3) compobj = dh.create_digest_entry(self.digestobj, today=three_days_ago) self.assertTrue(isinstance(compobj, models.DigestEntry))
def test_create_weekly_digest_entry_feed_date_created(self): """The models.DigestFeed object has it's `date_last_digest` attributed correctly updated when a digest entry is created.""" compobj = dh.create_digest_entry(self.digestobj, today=self.today) self.assertEqual(compobj.digest_feed.date_last_digest, self.today)
def test_create_weekly_digest_entry_date_created(self): "The models.DigestEntry object has the correct `date_created` updated." compobj = dh.create_digest_entry(self.digestobj, today=self.today) self.assertEqual(compobj.date_created, self.today)
def test_create_weekly_digest_entry(self): "A digest entry for a weekly digest feed is successfully created." compobj = dh.create_digest_entry(self.digestobj, today=self.today) self.assertTrue(isinstance(compobj, models.DigestEntry))
def test_create_digest_entry_duplicate(self): "The creation of a daily digest entry will fail to create a duplicate if a match already exists." compobj = dh.create_digest_entry(self.digestobj, today=self.today) self.assertTrue(isinstance(compobj, models.DigestEntry)) compobj2 = dh.create_digest_entry(self.digestobj, today=self.today) self.assertEqual(compobj.id, compobj2.id)
def test_create_digest_entry_force_date_feed(self): "Ensure a digest entry created in the past correctly updates it's feed's `date_last_updated` attribute." two_days_ago = self.today - timedelta(days=2) compobj = dh.create_digest_entry(self.digestobj, today=two_days_ago) self.assertNotEqual(compobj, None) self.assertEqual(self.digestobj.date_last_digest, two_days_ago)
def test_create_digest_entry_force_date(self): "Ensure a digest entry created in the past has the correct timestamp" two_days_ago = self.today - timedelta(days=2) compobj = dh.create_digest_entry(self.digestobj, today=two_days_ago) self.assertEqual(compobj.date_created, two_days_ago)
def test_create_digest_entry_date_created(self): """The `date_last_updated` attribute on the models.DigestFeed object is updated to the current date""" compobj = dh.create_digest_entry(self.digestobj, today=self.today) self.assertEqual(self.digestobj.date_last_digest, self.today)
def test_create_digest_entry(self): "Create a single models.DigestEntry object for the most recent period" compobj = dh.create_digest_entry(self.digestobj) self.assertTrue(isinstance(compobj, models.DigestEntry)) self.assertEqual(compobj.date_created, self.today)