1
0
mirror of https://github.com/django/django.git synced 2025-10-23 21:59:11 +00:00

Began implementing a shared set of test models to speed up tests.

This commit is contained in:
Florian Apolloner
2013-03-13 23:25:26 +01:00
parent 1059da8de6
commit 22b7870e40
5 changed files with 205 additions and 215 deletions

View File

@@ -16,6 +16,7 @@ from django.db import models
from django.utils import six
from django.utils.encoding import python_2_unicode_compatible
from shared_models.models import Author, Book
temp_storage_dir = tempfile.mkdtemp(dir=os.environ['DJANGO_TEST_TEMP_DIR'])
temp_storage = FileSystemStorage(temp_storage_dir)
@@ -44,23 +45,13 @@ class Category(models.Model):
def __repr__(self):
return self.__str__()
@python_2_unicode_compatible
class Writer(models.Model):
name = models.CharField(max_length=50, help_text='Use both first and last names.')
class Meta:
ordering = ('name',)
def __str__(self):
return self.name
@python_2_unicode_compatible
class Article(models.Model):
headline = models.CharField(max_length=50)
slug = models.SlugField()
pub_date = models.DateField()
created = models.DateField(editable=False)
writer = models.ForeignKey(Writer)
writer = models.ForeignKey(Author)
article = models.TextField()
categories = models.ManyToManyField(Category, blank=True)
status = models.PositiveIntegerField(choices=ARTICLE_STATUS, blank=True, null=True)
@@ -80,12 +71,12 @@ class ImprovedArticle(models.Model):
class ImprovedArticleWithParentLink(models.Model):
article = models.OneToOneField(Article, parent_link=True)
class BetterWriter(Writer):
class BetterAuthor(Author):
score = models.IntegerField()
@python_2_unicode_compatible
class WriterProfile(models.Model):
writer = models.OneToOneField(Writer, primary_key=True)
class AuthorProfile(models.Model):
writer = models.OneToOneField(Author, primary_key=True)
age = models.PositiveIntegerField()
def __str__(self):
@@ -192,14 +183,6 @@ class Inventory(models.Model):
def __repr__(self):
return self.__str__()
class Book(models.Model):
title = models.CharField(max_length=40)
author = models.ForeignKey(Writer, blank=True, null=True)
special_id = models.IntegerField(blank=True, null=True, unique=True)
class Meta:
unique_together = ('title', 'author')
class BookXtra(models.Model):
isbn = models.CharField(max_length=16, unique=True)
suffix1 = models.IntegerField(blank=True, default=0)