base.py 829 B

123456789101112131415161718192021222324252627282930
  1. from django.apps import apps
  2. from django.core.cache import cache
  3. from django.db import models
  4. from django.test import TestCase
  5. class TestModel(models.Model):
  6. name = models.CharField(max_length=100)
  7. class Meta:
  8. app_label = 'sitemaps'
  9. def __unicode__(self):
  10. return self.name
  11. def get_absolute_url(self):
  12. return '/testmodel/%s/' % self.id
  13. class SitemapTestsBase(TestCase):
  14. protocol = 'http'
  15. sites_installed = apps.is_installed('django.contrib.sites')
  16. domain = 'example.com' if sites_installed else 'testserver'
  17. urls = 'django.contrib.sitemaps.tests.urls.http'
  18. def setUp(self):
  19. self.base_url = '%s://%s' % (self.protocol, self.domain)
  20. cache.clear()
  21. # Create an object for sitemap content.
  22. TestModel.objects.create(name='Test Object')