Skip to content

Commit

Permalink
Moved contrib.sitemaps tests out of contrib.
Browse files Browse the repository at this point in the history
  • Loading branch information
timgraham committed Feb 11, 2015
1 parent d8341bf commit fbc467c
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 47 deletions.
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,5 @@ recursive-include django/contrib/gis/tests/geoapp/fixtures *
recursive-include django/contrib/gis/tests/geogapp/fixtures *
recursive-include django/contrib/gis/tests/relatedapp/fixtures *
recursive-include django/contrib/sitemaps/templates *
recursive-include django/contrib/sitemaps/tests/templates *
recursive-exclude * __pycache__
recursive-exclude * *.py[co]
42 changes: 0 additions & 42 deletions django/contrib/sitemaps/tests/base.py

This file was deleted.

File renamed without changes.
20 changes: 20 additions & 0 deletions tests/sitemaps_tests/base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from django.apps import apps
from django.core.cache import cache
from django.test import TestCase, modify_settings, override_settings

from .models import I18nTestModel, TestModel


@modify_settings(INSTALLED_APPS={'append': 'django.contrib.sitemaps'})
@override_settings(ROOT_URLCONF='sitemaps_tests.urls.http')
class SitemapTestsBase(TestCase):
protocol = 'http'
sites_installed = apps.is_installed('django.contrib.sites')
domain = 'example.com' if sites_installed else 'testserver'

def setUp(self):
self.base_url = '%s://%s' % (self.protocol, self.domain)
cache.clear()
# Create an object for sitemap content.
TestModel.objects.create(name='Test Object')
self.i18n_model = I18nTestModel.objects.create(name='Test Object')
16 changes: 16 additions & 0 deletions tests/sitemaps_tests/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from django.core.urlresolvers import reverse
from django.db import models


class TestModel(models.Model):
name = models.CharField(max_length=100)

def get_absolute_url(self):
return '/testmodel/%s/' % self.id


class I18nTestModel(models.Model):
name = models.CharField(max_length=100)

def get_absolute_url(self):
return reverse('i18n_testmodel', args=[self.id])
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

from django.test import override_settings

from .base import SitemapTestsBase, TestModel
from .base import SitemapTestsBase
from .models import TestModel


@override_settings(ABSOLUTE_URL_OVERRIDES={})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
from django.utils.formats import localize
from django.utils.translation import activate, deactivate

from .base import SitemapTestsBase, TestModel
from .base import SitemapTestsBase
from .models import TestModel


class HTTPSitemapTests(SitemapTestsBase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from .base import SitemapTestsBase


@override_settings(ROOT_URLCONF='django.contrib.sitemaps.tests.urls.https')
@override_settings(ROOT_URLCONF='sitemaps_tests.urls.https')
class HTTPSSitemapTests(SitemapTestsBase):
protocol = 'https'

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
from django.conf.urls import url
from django.conf.urls.i18n import i18n_patterns
from django.contrib.sitemaps import GenericSitemap, Sitemap, views
from django.contrib.sitemaps.tests.base import I18nTestModel, TestModel
from django.http import HttpResponse
from django.utils import timezone
from django.views.decorators.cache import cache_page

from ..models import I18nTestModel, TestModel


class SimpleSitemap(Sitemap):
changefreq = "never"
Expand Down
File renamed without changes.

0 comments on commit fbc467c

Please sign in to comment.