parent
a96dbda6d3
commit
b341f33697
|
@ -0,0 +1,66 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.core import validators
|
||||||
|
from django.db import models, migrations
|
||||||
|
from django.utils import timezone
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('contenttypes', '__first__'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Permission',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||||
|
('name', models.CharField(max_length=50, verbose_name='name')),
|
||||||
|
('content_type', models.ForeignKey(to='contenttypes.ContentType', to_field='id')),
|
||||||
|
('codename', models.CharField(max_length=100, verbose_name='codename')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'ordering': ('content_type__app_label', 'content_type__model', 'codename'),
|
||||||
|
'unique_together': set([('content_type', 'codename')]),
|
||||||
|
'verbose_name': 'permission',
|
||||||
|
'verbose_name_plural': 'permissions',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Group',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||||
|
('name', models.CharField(unique=True, max_length=80, verbose_name='name')),
|
||||||
|
('permissions', models.ManyToManyField(to='auth.Permission', verbose_name='permissions', blank=True)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'group',
|
||||||
|
'verbose_name_plural': 'groups',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='User',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||||
|
('password', models.CharField(max_length=128, verbose_name='password')),
|
||||||
|
('last_login', models.DateTimeField(default=timezone.now, verbose_name='last login')),
|
||||||
|
('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')),
|
||||||
|
('username', models.CharField(help_text='Required. 30 characters or fewer. Letters, digits and @/./+/-/_ only.', unique=True, max_length=30, verbose_name='username', validators=[validators.RegexValidator('^[\\w.@+-]+$', 'Enter a valid username.', 'invalid')])),
|
||||||
|
('first_name', models.CharField(max_length=30, verbose_name='first name', blank=True)),
|
||||||
|
('last_name', models.CharField(max_length=30, verbose_name='last name', blank=True)),
|
||||||
|
('email', models.EmailField(max_length=75, verbose_name='email address', blank=True)),
|
||||||
|
('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')),
|
||||||
|
('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')),
|
||||||
|
('date_joined', models.DateTimeField(default=timezone.now, verbose_name='date joined')),
|
||||||
|
('groups', models.ManyToManyField(to='auth.Group', verbose_name='groups', blank=True)),
|
||||||
|
('user_permissions', models.ManyToManyField(to='auth.Permission', verbose_name='user permissions', blank=True)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'swappable': 'AUTH_USER_MODEL',
|
||||||
|
'verbose_name': 'user',
|
||||||
|
'verbose_name_plural': 'users',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
|
@ -4,6 +4,7 @@ from django.test import TestCase, override_settings
|
||||||
from django.db import connection, connections
|
from django.db import connection, connections
|
||||||
from django.db.migrations.loader import MigrationLoader, AmbiguityError
|
from django.db.migrations.loader import MigrationLoader, AmbiguityError
|
||||||
from django.db.migrations.recorder import MigrationRecorder
|
from django.db.migrations.recorder import MigrationRecorder
|
||||||
|
from django.test import modify_settings
|
||||||
from django.utils import six
|
from django.utils import six
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,6 +47,7 @@ class LoaderTests(TestCase):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@override_settings(MIGRATION_MODULES={"migrations": "migrations.test_migrations"})
|
@override_settings(MIGRATION_MODULES={"migrations": "migrations.test_migrations"})
|
||||||
|
@modify_settings(INSTALLED_APPS={'append': 'basic'})
|
||||||
def test_load(self):
|
def test_load(self):
|
||||||
"""
|
"""
|
||||||
Makes sure the loader can load the migrations for the test apps,
|
Makes sure the loader can load the migrations for the test apps,
|
||||||
|
@ -77,7 +79,7 @@ class LoaderTests(TestCase):
|
||||||
)
|
)
|
||||||
|
|
||||||
# Ensure we've included unmigrated apps in there too
|
# Ensure we've included unmigrated apps in there too
|
||||||
self.assertIn("auth", project_state.real_apps)
|
self.assertIn("basic", project_state.real_apps)
|
||||||
|
|
||||||
@override_settings(MIGRATION_MODULES={"migrations": "migrations.test_migrations_unmigdep"})
|
@override_settings(MIGRATION_MODULES={"migrations": "migrations.test_migrations_unmigdep"})
|
||||||
def test_load_unmigrated_dependency(self):
|
def test_load_unmigrated_dependency(self):
|
||||||
|
@ -89,6 +91,8 @@ class LoaderTests(TestCase):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
migration_loader.graph.forwards_plan(("migrations", "0001_initial")),
|
migration_loader.graph.forwards_plan(("migrations", "0001_initial")),
|
||||||
[
|
[
|
||||||
|
('contenttypes', u'0001_initial'),
|
||||||
|
('auth', u'0001_initial'),
|
||||||
("migrations", "0001_initial"),
|
("migrations", "0001_initial"),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
|
@ -129,8 +129,9 @@ def setup(verbosity, test_labels):
|
||||||
# Ensure the middleware classes are seen as overridden otherwise we get a compatibility warning.
|
# Ensure the middleware classes are seen as overridden otherwise we get a compatibility warning.
|
||||||
settings._explicit_settings.add('MIDDLEWARE_CLASSES')
|
settings._explicit_settings.add('MIDDLEWARE_CLASSES')
|
||||||
settings.MIGRATION_MODULES = {
|
settings.MIGRATION_MODULES = {
|
||||||
# this module doesn't actually exist, but this lets us skip creating
|
# these 'tests.migrations' modules don't actually exist, but this lets
|
||||||
# migrations for the test modules for some reason.
|
# us skip creating migrations for the test models.
|
||||||
|
'auth': 'django.contrib.auth.tests.migrations',
|
||||||
'contenttypes': 'django.contrib.contenttypes.tests.migrations',
|
'contenttypes': 'django.contrib.contenttypes.tests.migrations',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -325,7 +325,7 @@ LOGIN_URL = reverse_lazy('login')""")
|
||||||
self.remove_settings('settings.py')
|
self.remove_settings('settings.py')
|
||||||
|
|
||||||
def test_lazy_in_settings(self):
|
def test_lazy_in_settings(self):
|
||||||
out, err = self.run_manage(['sqlall', 'auth'])
|
out, err = self.run_manage(['validate'])
|
||||||
self.assertNoOutput(err)
|
self.assertNoOutput(err)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue