You have been requested to review the proposed merge of
lp:~daker/loco-directory/ltp-blog-fixes into
lp:~chrisjohnston/loco-directory/LTP-Blogroll.
For more details, see:
https://code.launchpad.net/~daker/loco-directory/ltp-blog-fixes/+merge/73095
--
https://code.launchpad.net/~daker/loco-directory/ltp-blog-fixes/+merge/73095
Your team loco-directory-dev is requested to review the proposed merge of
lp:~daker/loco-directory/ltp-blog-fixes into
lp:~chrisjohnston/loco-directory/LTP-Blogroll.
=== modified file 'loco_directory/articles/models.py'
--- loco_directory/articles/models.py 2011-06-02 12:08:30 +0000
+++ loco_directory/articles/models.py 2011-08-26 19:58:28 +0000
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
import feedparser
import time
import datetime
@@ -30,18 +31,16 @@
return '%s:%s' % (feed.id, hash(entry.title))
class Feed(models.Model):
-
- class Meta:
- ordering = ('title',)
-
user = models.ForeignKey(UserProfile, blank=True, null=True)
team = models.ForeignKey(Team, blank=True, null=True)
url = models.URLField()
title = models.CharField(max_length=128, null=True, blank=True)
last_updated = models.DateTimeField(null=False, blank=False, default=datetime.datetime(1970, 1, 1))
-
active = models.BooleanField(default=True)
-
+
+ class Meta:
+ ordering = ('title',)
+
def __unicode__(self):
return self.title
@@ -99,10 +98,6 @@
Article.objects.filter(source=self, uid__in=obsolete_articles).delete()
class Article(models.Model):
-
- class Meta:
- ordering = ['-imported', '-published',]
-
source = models.ForeignKey(Feed, null=True, blank=True)
uid = models.CharField(max_length=256)
author = models.CharField(max_length=128, null=True, blank=True)
@@ -111,7 +106,9 @@
link = models.URLField(max_length=1024, null=True, blank=True)
title = models.CharField(max_length=128, null=True, blank=True)
snippet = models.CharField(max_length=512, null=True, blank=True)
-
+
+ class Meta:
+ ordering = ['-imported', '-published',]
+
def __unicode__(self):
- return '%s (%s)' % (self.title, self.author)
-
+ return u'%s (%s)' % (self.title, self.author)
=== modified file 'loco_directory/articles/tests.py'
--- loco_directory/articles/tests.py 2011-06-01 22:19:20 +0000
+++ loco_directory/articles/tests.py 2011-08-26 19:58:28 +0000
@@ -1,23 +1,32 @@
-"""
-This file demonstrates two different styles of tests (one doctest and one
-unittest). These will both pass when you run "manage.py test".
-
-Replace these with more appropriate tests for your application.
-"""
-
from django.test import TestCase
-
-class SimpleTest(TestCase):
- def test_basic_addition(self):
- """
- Tests that 1 + 1 always equals 2.
- """
- self.failUnlessEqual(1 + 1, 2)
-
-__test__ = {"doctest": """
-Another way to test that 1 + 1 is equal to 2.
-
->>> 1 + 1 == 2
-True
-"""}
-
+from django.test.client import Client
+
+from articles.models import Feed, Article
+
+class ArticlesTests(TestCase):
+
+ def setUp(self):
+ super(ArticlesTests, self).setUp()
+ self.feed_url = 'http://www.canonical.com/rss.xml'
+ self.feed = Feed.objects.create(url=self.feed_url, title="Canonical")
+
+ def test_environment(self):
+ """Just make sure everything is set up correctly."""
+ self.assert_(True)
+ try:
+ import feedparser
+ except:
+ self.assert_(False)
+
+ def test_update(self):
+ """Update and check for new articles"""
+ self.feed.update(first_load=True)
+ articles = Article.objects.all()
+ self.assertEqual(len(articles), 10)
+
+ def test_check_duplicate(self):
+ """Update and check for for duplicated articles"""
+ feed = Feed.objects.get(url=self.feed_url)
+ feed.update()
+ articles = Article.objects.all()
+ self.assertEqual(len(articles), 10)
_______________________________________________
Mailing list: https://launchpad.net/~loco-directory-dev
Post to : [email protected]
Unsubscribe : https://launchpad.net/~loco-directory-dev
More help : https://help.launchpad.net/ListHelp