Ticket #11069: feed_testcases_r10731.diff

File feed_testcases_r10731.diff, 4.6 KB (added by Arthur Koziel, 15 years ago)
  • tests/regressiontests/syndication/feeds.py

    diff --git a/tests/regressiontests/syndication/feeds.py b/tests/regressiontests/syndication/feeds.py
    index 79837f9..098cd27 100644
    a b class TestRssFeed(feeds.Feed):  
    1616    def items(self):
    1717        from models import Entry
    1818        return Entry.objects.all()
    19        
    20     def item_link(self, item):
    21         return "/blog/%s/" % item.pk
    2219
    2320class TestAtomFeed(TestRssFeed):
    2421    feed_type = Atom1Feed
    2522
     23class ArticlesFeed(TestRssFeed):
     24    def items(self):
     25        from models import Article
     26        return Article.objects.all()
     27
    2628class MyCustomAtom1Feed(Atom1Feed):
    2729    """
    2830    Test of a custom feed generator class.
  • tests/regressiontests/syndication/fixtures/feeddata.json

    diff --git a/tests/regressiontests/syndication/fixtures/feeddata.json b/tests/regressiontests/syndication/fixtures/feeddata.json
    index 375ee16..fdc373d 100644
    a b  
    3030      "title": "A & B < C > D",
    3131      "date": "2008-01-03 13:30:00"
    3232    }
     33  },
     34  {
     35    "model": "syndication.article",
     36    "pk": 1,
     37    "fields": {
     38      "title": "My first article",
     39      "entry": "1"
     40    }
    3341  }
    3442]
     43 No newline at end of file
  • tests/regressiontests/syndication/models.py

    diff --git a/tests/regressiontests/syndication/models.py b/tests/regressiontests/syndication/models.py
    index 99e14ad..02b5e56 100644
    a b class Entry(models.Model):  
    55    date = models.DateTimeField()
    66   
    77    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
     13class Article(models.Model):
     14    title = models.CharField(max_length=200)
     15    entry = models.ForeignKey(Entry)
     16
     17    def __unicode__(self):
     18        return self.title
  • tests/regressiontests/syndication/tests.py

    diff --git a/tests/regressiontests/syndication/tests.py b/tests/regressiontests/syndication/tests.py
    index 816cb44..a0bce64 100644
    a b  
    22
    33import datetime
    44from xml.dom import minidom
     5from django.core.exceptions import ImproperlyConfigured
    56from django.test import TestCase
    67from django.test.client import Client
    78from django.utils import tzinfo
    class SyndicationFeedTest(TestCase):  
    7778       
    7879    def test_complex_base_url(self):
    7980        """
    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
    8182        exception.
    8283        """
    8384        response = self.client.get('/syndication/feeds/complex/')
    class SyndicationFeedTest(TestCase):  
    116117        doc = minidom.parseString(response.content)
    117118        updated = doc.getElementsByTagName('updated')[0].firstChild.wholeText
    118119        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/')
  • tests/regressiontests/syndication/urls.py

    diff --git a/tests/regressiontests/syndication/urls.py b/tests/regressiontests/syndication/urls.py
    index ec45026..7339fa9 100644
    a b feed_dict = {  
    77    'atom': feeds.TestAtomFeed,
    88    'custom': feeds.TestCustomFeed,
    99    'naive-dates': feeds.NaiveDatesFeed,
    10     'aware-dates': feeds.TZAwareDatesFeed,   
     10    'aware-dates': feeds.TZAwareDatesFeed,
     11    'articles': feeds.ArticlesFeed,
    1112}
    1213urlpatterns = 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})
    1416)
Back to Top