2014-02-02 00:37:08 +08:00
|
|
|
from django.apps import apps
|
2012-10-16 03:08:07 +08:00
|
|
|
from django.core.cache import cache
|
2013-03-23 09:57:48 +08:00
|
|
|
from django.db import models
|
2014-04-05 14:04:46 +08:00
|
|
|
from django.test import TestCase, override_settings
|
2012-01-30 03:24:32 +08:00
|
|
|
|
|
|
|
|
2013-03-23 09:57:48 +08:00
|
|
|
class TestModel(models.Model):
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
app_label = 'sitemaps'
|
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
return self.name
|
|
|
|
|
|
|
|
def get_absolute_url(self):
|
|
|
|
return '/testmodel/%s/' % self.id
|
|
|
|
|
|
|
|
|
2014-04-05 14:04:46 +08:00
|
|
|
@override_settings(ROOT_URLCONF='django.contrib.sitemaps.tests.urls.http')
|
2012-01-30 03:24:32 +08:00
|
|
|
class SitemapTestsBase(TestCase):
|
|
|
|
protocol = 'http'
|
2014-02-02 00:37:08 +08:00
|
|
|
sites_installed = apps.is_installed('django.contrib.sites')
|
|
|
|
domain = 'example.com' if sites_installed else 'testserver'
|
2012-01-30 03:24:32 +08:00
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
self.base_url = '%s://%s' % (self.protocol, self.domain)
|
2012-10-16 03:08:07 +08:00
|
|
|
cache.clear()
|
2013-03-23 09:57:48 +08:00
|
|
|
# Create an object for sitemap content.
|
|
|
|
TestModel.objects.create(name='Test Object')
|