From e1046a96bcb996c34b79974e21575d718f6b5739 Mon Sep 17 00:00:00 2001
From: Tim Graham <timograham@gmail.com>
Date: Tue, 10 Feb 2015 08:11:25 -0500
Subject: [PATCH] [1.8.x] Moved contrib.sitemaps tests out of contrib.

Backport of fbc467c26bc0adb9867b97d0bb5642b2a85eb357 from master
---
 MANIFEST.in                                   |  1 -
 django/contrib/sitemaps/tests/base.py         | 42 -------------------
 .../sitemaps_tests}/__init__.py               |  0
 tests/sitemaps_tests/base.py                  | 20 +++++++++
 tests/sitemaps_tests/models.py                | 16 +++++++
 .../templates/custom_sitemap.xml              |  0
 .../templates/custom_sitemap_index.xml        |  0
 .../sitemaps_tests}/test_generic.py           |  3 +-
 .../sitemaps_tests}/test_http.py              |  3 +-
 .../sitemaps_tests}/test_https.py             |  2 +-
 .../sitemaps_tests}/urls/__init__.py          |  0
 .../sitemaps_tests}/urls/http.py              |  3 +-
 .../sitemaps_tests}/urls/https.py             |  0
 13 files changed, 43 insertions(+), 47 deletions(-)
 delete mode 100644 django/contrib/sitemaps/tests/base.py
 rename {django/contrib/sitemaps/tests => tests/sitemaps_tests}/__init__.py (100%)
 create mode 100644 tests/sitemaps_tests/base.py
 create mode 100644 tests/sitemaps_tests/models.py
 rename {django/contrib/sitemaps/tests => tests/sitemaps_tests}/templates/custom_sitemap.xml (100%)
 rename {django/contrib/sitemaps/tests => tests/sitemaps_tests}/templates/custom_sitemap_index.xml (100%)
 rename {django/contrib/sitemaps/tests => tests/sitemaps_tests}/test_generic.py (91%)
 rename {django/contrib/sitemaps/tests => tests/sitemaps_tests}/test_http.py (99%)
 rename {django/contrib/sitemaps/tests => tests/sitemaps_tests}/test_https.py (97%)
 rename {django/contrib/sitemaps/tests => tests/sitemaps_tests}/urls/__init__.py (100%)
 rename {django/contrib/sitemaps/tests => tests/sitemaps_tests}/urls/http.py (98%)
 rename {django/contrib/sitemaps/tests => tests/sitemaps_tests}/urls/https.py (100%)

diff --git a/MANIFEST.in b/MANIFEST.in
index 03464ceff1..94437d69a3 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -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]
diff --git a/django/contrib/sitemaps/tests/base.py b/django/contrib/sitemaps/tests/base.py
deleted file mode 100644
index a218e60c3e..0000000000
--- a/django/contrib/sitemaps/tests/base.py
+++ /dev/null
@@ -1,42 +0,0 @@
-from django.apps import apps
-from django.core.cache import cache
-from django.core.urlresolvers import reverse
-from django.db import models
-from django.test import TestCase, override_settings
-
-
-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
-
-
-class I18nTestModel(models.Model):
-    name = models.CharField(max_length=100)
-
-    class Meta:
-        app_label = 'sitemaps'
-
-    def get_absolute_url(self):
-        return reverse('i18n_testmodel', args=[self.id])
-
-
-@override_settings(ROOT_URLCONF='django.contrib.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')
diff --git a/django/contrib/sitemaps/tests/__init__.py b/tests/sitemaps_tests/__init__.py
similarity index 100%
rename from django/contrib/sitemaps/tests/__init__.py
rename to tests/sitemaps_tests/__init__.py
diff --git a/tests/sitemaps_tests/base.py b/tests/sitemaps_tests/base.py
new file mode 100644
index 0000000000..c3476cf08e
--- /dev/null
+++ b/tests/sitemaps_tests/base.py
@@ -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')
diff --git a/tests/sitemaps_tests/models.py b/tests/sitemaps_tests/models.py
new file mode 100644
index 0000000000..c155c848ba
--- /dev/null
+++ b/tests/sitemaps_tests/models.py
@@ -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])
diff --git a/django/contrib/sitemaps/tests/templates/custom_sitemap.xml b/tests/sitemaps_tests/templates/custom_sitemap.xml
similarity index 100%
rename from django/contrib/sitemaps/tests/templates/custom_sitemap.xml
rename to tests/sitemaps_tests/templates/custom_sitemap.xml
diff --git a/django/contrib/sitemaps/tests/templates/custom_sitemap_index.xml b/tests/sitemaps_tests/templates/custom_sitemap_index.xml
similarity index 100%
rename from django/contrib/sitemaps/tests/templates/custom_sitemap_index.xml
rename to tests/sitemaps_tests/templates/custom_sitemap_index.xml
diff --git a/django/contrib/sitemaps/tests/test_generic.py b/tests/sitemaps_tests/test_generic.py
similarity index 91%
rename from django/contrib/sitemaps/tests/test_generic.py
rename to tests/sitemaps_tests/test_generic.py
index 8dd8bdce09..96736c261a 100644
--- a/django/contrib/sitemaps/tests/test_generic.py
+++ b/tests/sitemaps_tests/test_generic.py
@@ -2,7 +2,8 @@ from __future__ import unicode_literals
 
 from django.test import override_settings
 
-from .base import SitemapTestsBase, TestModel
+from .base import SitemapTestsBase
+from .models import TestModel
 
 
 @override_settings(ABSOLUTE_URL_OVERRIDES={})
diff --git a/django/contrib/sitemaps/tests/test_http.py b/tests/sitemaps_tests/test_http.py
similarity index 99%
rename from django/contrib/sitemaps/tests/test_http.py
rename to tests/sitemaps_tests/test_http.py
index d3885ac1f1..2817f844d6 100644
--- a/django/contrib/sitemaps/tests/test_http.py
+++ b/tests/sitemaps_tests/test_http.py
@@ -15,7 +15,8 @@ from django.utils.deprecation import RemovedInDjango20Warning
 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):
diff --git a/django/contrib/sitemaps/tests/test_https.py b/tests/sitemaps_tests/test_https.py
similarity index 97%
rename from django/contrib/sitemaps/tests/test_https.py
rename to tests/sitemaps_tests/test_https.py
index 95537ae412..f7b363dfe2 100644
--- a/django/contrib/sitemaps/tests/test_https.py
+++ b/tests/sitemaps_tests/test_https.py
@@ -8,7 +8,7 @@ from django.utils.deprecation import RemovedInDjango20Warning
 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'
 
diff --git a/django/contrib/sitemaps/tests/urls/__init__.py b/tests/sitemaps_tests/urls/__init__.py
similarity index 100%
rename from django/contrib/sitemaps/tests/urls/__init__.py
rename to tests/sitemaps_tests/urls/__init__.py
diff --git a/django/contrib/sitemaps/tests/urls/http.py b/tests/sitemaps_tests/urls/http.py
similarity index 98%
rename from django/contrib/sitemaps/tests/urls/http.py
rename to tests/sitemaps_tests/urls/http.py
index e66dbb3b96..9a6004d40c 100644
--- a/django/contrib/sitemaps/tests/urls/http.py
+++ b/tests/sitemaps_tests/urls/http.py
@@ -5,11 +5,12 @@ from django.conf.urls.i18n import i18n_patterns
 from django.contrib.sitemaps import (
     FlatPageSitemap, 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"
diff --git a/django/contrib/sitemaps/tests/urls/https.py b/tests/sitemaps_tests/urls/https.py
similarity index 100%
rename from django/contrib/sitemaps/tests/urls/https.py
rename to tests/sitemaps_tests/urls/https.py