2008-03-20 06:35:53 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2008-08-11 20:49:19 +00:00
|
|
|
from xml.dom import minidom
|
2008-03-20 06:35:53 +00:00
|
|
|
from django.test import TestCase
|
|
|
|
from django.test.client import Client
|
2008-08-11 20:49:19 +00:00
|
|
|
from models import Entry
|
2008-03-20 06:35:53 +00:00
|
|
|
|
|
|
|
class SyndicationFeedTest(TestCase):
|
2008-08-11 20:49:19 +00:00
|
|
|
fixtures = ['feeddata.json']
|
|
|
|
|
|
|
|
def test_rss_feed(self):
|
|
|
|
response = self.client.get('/syndication/feeds/rss/')
|
|
|
|
doc = minidom.parseString(response.content)
|
|
|
|
self.assertEqual(len(doc.getElementsByTagName('channel')), 1)
|
|
|
|
self.assertEqual(len(doc.getElementsByTagName('item')), Entry.objects.count())
|
|
|
|
|
|
|
|
def test_atom_feed(self):
|
|
|
|
response = self.client.get('/syndication/feeds/atom/')
|
|
|
|
doc = minidom.parseString(response.content)
|
|
|
|
self.assertEqual(len(doc.getElementsByTagName('feed')), 1)
|
|
|
|
self.assertEqual(len(doc.getElementsByTagName('entry')), Entry.objects.count())
|
|
|
|
|
2008-03-20 06:35:53 +00:00
|
|
|
def test_complex_base_url(self):
|
|
|
|
"""
|
|
|
|
Tests that that the base url for a complex feed doesn't raise a 500
|
|
|
|
exception.
|
|
|
|
"""
|
2008-08-11 20:49:19 +00:00
|
|
|
response = self.client.get('/syndication/feeds/complex/')
|
2008-03-20 06:35:53 +00:00
|
|
|
self.assertEquals(response.status_code, 404)
|
2008-08-11 20:49:19 +00:00
|
|
|
|
|
|
|
|