Skip to content

Instantly share code, notes, and snippets.

@vladimirnani
Created December 23, 2013 07:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vladimirnani/8093185 to your computer and use it in GitHub Desktop.
Save vladimirnani/8093185 to your computer and use it in GitHub Desktop.
Test all urls defined in settings.py
from django.test import TestCase
from django.core.urlresolvers import reverse
from django_project.sitemaps import StaticSitemap
from django_project.urls import sitemaps
class StaticSitemapTests(TestCase):
def setUp(self):
names = [name for s in sitemaps.values()
if isinstance(s, StaticSitemap)
for name in s.names]
self.urls = names
def test_sitemap(self):
"""
Every url should return HTTP_200_OK
"""
for url in self.urls:
response = self.client.get(reverse(url))
self.assertEqual(response.status_code, 200)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment