diff --git a/tests/regressiontests/syndication/feeds.py b/tests/regressiontests/syndication/feeds.py
index 79837f9..098cd27 100644
a
|
b
|
class TestRssFeed(feeds.Feed):
|
16 | 16 | def items(self): |
17 | 17 | from models import Entry |
18 | 18 | return Entry.objects.all() |
19 | | |
20 | | def item_link(self, item): |
21 | | return "/blog/%s/" % item.pk |
22 | 19 | |
23 | 20 | class TestAtomFeed(TestRssFeed): |
24 | 21 | feed_type = Atom1Feed |
25 | 22 | |
| 23 | class ArticlesFeed(TestRssFeed): |
| 24 | def items(self): |
| 25 | from models import Article |
| 26 | return Article.objects.all() |
| 27 | |
26 | 28 | class MyCustomAtom1Feed(Atom1Feed): |
27 | 29 | """ |
28 | 30 | Test of a custom feed generator class. |
diff --git a/tests/regressiontests/syndication/fixtures/feeddata.json b/tests/regressiontests/syndication/fixtures/feeddata.json
index 375ee16..fdc373d 100644
a
|
b
|
|
30 | 30 | "title": "A & B < C > D", |
31 | 31 | "date": "2008-01-03 13:30:00" |
32 | 32 | } |
| 33 | }, |
| 34 | { |
| 35 | "model": "syndication.article", |
| 36 | "pk": 1, |
| 37 | "fields": { |
| 38 | "title": "My first article", |
| 39 | "entry": "1" |
| 40 | } |
33 | 41 | } |
34 | 42 | ] |
| 43 | No newline at end of file |
diff --git a/tests/regressiontests/syndication/models.py b/tests/regressiontests/syndication/models.py
index 99e14ad..02b5e56 100644
a
|
b
|
class Entry(models.Model):
|
5 | 5 | date = models.DateTimeField() |
6 | 6 | |
7 | 7 | def __unicode__(self): |
8 | | return self.title |
9 | | No newline at end of file |
| 8 | return self.title |
| 9 | |
| 10 | def get_absolute_url(self): |
| 11 | return "/blog/%s/" % self.pk |
| 12 | |
| 13 | class Article(models.Model): |
| 14 | title = models.CharField(max_length=200) |
| 15 | entry = models.ForeignKey(Entry) |
| 16 | |
| 17 | def __unicode__(self): |
| 18 | return self.title |
diff --git a/tests/regressiontests/syndication/tests.py b/tests/regressiontests/syndication/tests.py
index 816cb44..a0bce64 100644
a
|
b
|
|
2 | 2 | |
3 | 3 | import datetime |
4 | 4 | from xml.dom import minidom |
| 5 | from django.core.exceptions import ImproperlyConfigured |
5 | 6 | from django.test import TestCase |
6 | 7 | from django.test.client import Client |
7 | 8 | from django.utils import tzinfo |
… |
… |
class SyndicationFeedTest(TestCase):
|
77 | 78 | |
78 | 79 | def test_complex_base_url(self): |
79 | 80 | """ |
80 | | Tests that that the base url for a complex feed doesn't raise a 500 |
| 81 | Tests that the base url for a complex feed doesn't raise a 500 |
81 | 82 | exception. |
82 | 83 | """ |
83 | 84 | response = self.client.get('/syndication/feeds/complex/') |
… |
… |
class SyndicationFeedTest(TestCase):
|
116 | 117 | doc = minidom.parseString(response.content) |
117 | 118 | updated = doc.getElementsByTagName('updated')[0].firstChild.wholeText |
118 | 119 | self.assertEqual(updated[-6:], '+00:42') |
119 | | |
120 | | No newline at end of file |
| 120 | |
| 121 | def test_empty_feed_dict(self): |
| 122 | """ |
| 123 | Test that an empty feed_dict raises a 404. |
| 124 | """ |
| 125 | response = self.client.get('/syndication/feeds2/aware-dates/') |
| 126 | self.assertEquals(response.status_code, 404) |
| 127 | |
| 128 | def test_nonexistent_slug(self): |
| 129 | """ |
| 130 | Test that a non-existent slug raises a 404. |
| 131 | """ |
| 132 | response = self.client.get('/syndication/feeds/foobar/') |
| 133 | self.assertEquals(response.status_code, 404) |
| 134 | |
| 135 | def test_item_link_error(self): |
| 136 | """ |
| 137 | Test that a ImproperlyConfigured is raised if no link could be found |
| 138 | for the item(s). |
| 139 | """ |
| 140 | self.assertRaises(ImproperlyConfigured, |
| 141 | self.client.get, |
| 142 | '/syndication/feeds/articles/') |
diff --git a/tests/regressiontests/syndication/urls.py b/tests/regressiontests/syndication/urls.py
index ec45026..7339fa9 100644
a
|
b
|
feed_dict = {
|
7 | 7 | 'atom': feeds.TestAtomFeed, |
8 | 8 | 'custom': feeds.TestCustomFeed, |
9 | 9 | 'naive-dates': feeds.NaiveDatesFeed, |
10 | | 'aware-dates': feeds.TZAwareDatesFeed, |
| 10 | 'aware-dates': feeds.TZAwareDatesFeed, |
| 11 | 'articles': feeds.ArticlesFeed, |
11 | 12 | } |
12 | 13 | urlpatterns = patterns('', |
13 | | (r'^feeds/(?P<url>.*)/$', 'django.contrib.syndication.views.feed', {'feed_dict': feed_dict}) |
| 14 | (r'^feeds/(?P<url>.*)/$', 'django.contrib.syndication.views.feed', {'feed_dict': feed_dict}), |
| 15 | (r'^feeds2/(?P<url>.*)/$', 'django.contrib.syndication.views.feed', {'feed_dict': None}) |
14 | 16 | ) |