summaryrefslogtreecommitdiff
path: root/tests/contenttypes_tests/tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/contenttypes_tests/tests.py')
-rw-r--r--tests/contenttypes_tests/tests.py30
1 files changed, 27 insertions, 3 deletions
diff --git a/tests/contenttypes_tests/tests.py b/tests/contenttypes_tests/tests.py
index a791f8df3c..3ae4774033 100644
--- a/tests/contenttypes_tests/tests.py
+++ b/tests/contenttypes_tests/tests.py
@@ -1,12 +1,15 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
+import datetime
+
from django.apps.registry import Apps, apps
from django.contrib.contenttypes import management
from django.contrib.contenttypes.fields import (
GenericForeignKey, GenericRelation,
)
from django.contrib.contenttypes.models import ContentType
+from django.contrib.sites.models import Site
from django.core import checks
from django.db import connections, models
from django.test import TestCase, override_settings
@@ -18,7 +21,29 @@ from .models import Article, Author, SchemeIncludedURL
@override_settings(ROOT_URLCONF='contenttypes_tests.urls')
class ContentTypesViewsTests(TestCase):
- fixtures = ['testdata.json']
+
+ @classmethod
+ def setUpTestData(cls):
+ # don't use the manager because we want to ensure the site exists
+ # with pk=1, regardless of whether or not it already exists.
+ cls.site1 = Site(pk=1, domain='testserver', name='testserver')
+ cls.site1.save()
+ cls.author1 = Author.objects.create(name='Boris')
+ cls.article1 = Article.objects.create(
+ title='Old Article', slug='old_article', author=cls.author1,
+ date_created=datetime.datetime(2001, 1, 1, 21, 22, 23)
+ )
+ cls.article2 = Article.objects.create(
+ title='Current Article', slug='current_article', author=cls.author1,
+ date_created=datetime.datetime(2007, 9, 17, 21, 22, 23)
+ )
+ cls.article3 = Article.objects.create(
+ title='Future Article', slug='future_article', author=cls.author1,
+ date_created=datetime.datetime(3000, 1, 1, 21, 22, 23)
+ )
+ cls.scheme1 = SchemeIncludedURL.objects.create(url='http://test_scheme_included_http/')
+ cls.scheme2 = SchemeIncludedURL.objects.create(url='https://test_scheme_included_https/')
+ cls.scheme3 = SchemeIncludedURL.objects.create(url='//test_default_scheme_kept/')
def test_shortcut_with_absolute_url(self):
"Can view a shortcut for an Author object that has a get_absolute_url method"
@@ -31,8 +56,7 @@ class ContentTypesViewsTests(TestCase):
def test_shortcut_with_absolute_url_including_scheme(self):
"""
Can view a shortcut when object's get_absolute_url returns a full URL
- the tested URLs are in fixtures/testdata.json :
- "http://...", "https://..." and "//..."
+ the tested URLs are: "http://...", "https://..." and "//..."
"""
for obj in SchemeIncludedURL.objects.all():
short_url = '/shortcut/%s/%s/' % (ContentType.objects.get_for_model(SchemeIncludedURL).id, obj.pk)