diff options
Diffstat (limited to 'django')
| -rw-r--r-- | django/contrib/contenttypes/migrations/0001_initial.py | 33 | ||||
| -rw-r--r-- | django/contrib/contenttypes/migrations/__init__.py | 0 | ||||
| -rw-r--r-- | django/contrib/contenttypes/models.py | 2 | ||||
| -rw-r--r-- | django/contrib/contenttypes/tests/__init__.py | 0 | ||||
| -rw-r--r-- | django/contrib/contenttypes/tests/models.py | 43 | ||||
| -rw-r--r-- | django/contrib/contenttypes/tests/tests.py (renamed from django/contrib/contenttypes/tests.py) | 42 |
6 files changed, 79 insertions, 41 deletions
diff --git a/django/contrib/contenttypes/migrations/0001_initial.py b/django/contrib/contenttypes/migrations/0001_initial.py new file mode 100644 index 0000000000..08e1119376 --- /dev/null +++ b/django/contrib/contenttypes/migrations/0001_initial.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='ContentType', + fields=[ + ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('name', models.CharField(max_length=100)), + ('app_label', models.CharField(max_length=100)), + ('model', models.CharField(max_length=100, verbose_name='python model class name')), + ], + options={ + 'ordering': ('name',), + 'db_table': 'django_content_type', + 'verbose_name': 'content type', + 'verbose_name_plural': 'content types', + }, + bases=(models.Model,), + ), + migrations.AlterUniqueTogether( + name='contenttype', + unique_together=set([('app_label', 'model')]), + ), + ] diff --git a/django/contrib/contenttypes/migrations/__init__.py b/django/contrib/contenttypes/migrations/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/django/contrib/contenttypes/migrations/__init__.py diff --git a/django/contrib/contenttypes/models.py b/django/contrib/contenttypes/models.py index 634576f4d0..c54defb459 100644 --- a/django/contrib/contenttypes/models.py +++ b/django/contrib/contenttypes/models.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from django.apps import apps from django.db import models from django.utils.translation import ugettext_lazy as _ diff --git a/django/contrib/contenttypes/tests/__init__.py b/django/contrib/contenttypes/tests/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/django/contrib/contenttypes/tests/__init__.py diff --git a/django/contrib/contenttypes/tests/models.py b/django/contrib/contenttypes/tests/models.py new file mode 100644 index 0000000000..a173f091bd --- /dev/null +++ b/django/contrib/contenttypes/tests/models.py @@ -0,0 +1,43 @@ +from django.db import models +from django.utils.encoding import python_2_unicode_compatible +from django.utils.http import urlquote + + +class ConcreteModel(models.Model): + name = models.CharField(max_length=10) + + +class ProxyModel(ConcreteModel): + class Meta: + proxy = True + + +@python_2_unicode_compatible +class FooWithoutUrl(models.Model): + """ + Fake model not defining ``get_absolute_url`` for + ContentTypesTests.test_shortcut_view_without_get_absolute_url() + """ + name = models.CharField(max_length=30, unique=True) + + def __str__(self): + return self.name + + +class FooWithUrl(FooWithoutUrl): + """ + Fake model defining ``get_absolute_url`` for + ContentTypesTests.test_shortcut_view(). + """ + + def get_absolute_url(self): + return "/users/%s/" % urlquote(self.name) + + +class FooWithBrokenAbsoluteUrl(FooWithoutUrl): + """ + Fake model defining a ``get_absolute_url`` method containing an error + """ + + def get_absolute_url(self): + return "/users/%s/" % self.unknown_field diff --git a/django/contrib/contenttypes/tests.py b/django/contrib/contenttypes/tests/tests.py index 6ee34adb4a..924ffdca46 100644 --- a/django/contrib/contenttypes/tests.py +++ b/django/contrib/contenttypes/tests/tests.py @@ -3,51 +3,11 @@ from __future__ import unicode_literals from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.views import shortcut from django.contrib.sites.shortcuts import get_current_site -from django.db import models from django.http import HttpRequest, Http404 from django.test import TestCase, override_settings -from django.utils.http import urlquote from django.utils import six -from django.utils.encoding import python_2_unicode_compatible - -class ConcreteModel(models.Model): - name = models.CharField(max_length=10) - - -class ProxyModel(ConcreteModel): - class Meta: - proxy = True - - -@python_2_unicode_compatible -class FooWithoutUrl(models.Model): - """ - Fake model not defining ``get_absolute_url`` for - :meth:`ContentTypesTests.test_shortcut_view_without_get_absolute_url`""" - name = models.CharField(max_length=30, unique=True) - - def __str__(self): - return self.name - - -class FooWithUrl(FooWithoutUrl): - """ - Fake model defining ``get_absolute_url`` for - :meth:`ContentTypesTests.test_shortcut_view` - """ - - def get_absolute_url(self): - return "/users/%s/" % urlquote(self.name) - - -class FooWithBrokenAbsoluteUrl(FooWithoutUrl): - """ - Fake model defining a ``get_absolute_url`` method containing an error - """ - - def get_absolute_url(self): - return "/users/%s/" % self.unknown_field +from .models import ConcreteModel, ProxyModel, FooWithoutUrl, FooWithUrl, FooWithBrokenAbsoluteUrl class ContentTypesTests(TestCase): |
