Moved test models in tests module to fix issue #2.

This commit is contained in:
Jannis Leidel 2009-08-16 15:38:34 +02:00
parent ac73853f61
commit 277f3260bb
8 changed files with 67 additions and 56 deletions

View File

@ -1 +0,0 @@
[{"pk": 1, "model": "django_filters.user", "fields": {"username": "alex", "status": 1, "first_name": "", "last_name": "", "favorite_books": [1, 2], "is_active": false}}, {"pk": 2, "model": "django_filters.user", "fields": {"username": "aaron", "status": 0, "first_name": "", "last_name": "", "favorite_books": [1, 3], "is_active": false}}, {"pk": 3, "model": "django_filters.user", "fields": {"username": "jacob", "status": 0, "first_name": "", "last_name": "", "favorite_books": [], "is_active": true}}, {"pk": 1, "model": "django_filters.comment", "fields": {"date": "2009-01-30", "text": "super awesome!", "time": "03:04:05", "author": 1}}, {"pk": 2, "model": "django_filters.comment", "fields": {"date": "2009-01-27", "text": "psycadelic!", "time": "05:04:03", "author": 2}}, {"pk": 3, "model": "django_filters.comment", "fields": {"date": "2008-12-31", "text": "funky fresh!", "time": "12:55:00", "author": 3}}, {"pk": 1, "model": "django_filters.book", "fields": {"average_rating": 4.7999999999999998, "price": "10", "title": "Ender's Game"}}, {"pk": 2, "model": "django_filters.book", "fields": {"average_rating": 4.5999999999999996, "price": "15", "title": "Rainbox Six"}}, {"pk": 3, "model": "django_filters.book", "fields": {"average_rating": 4.2999999999999998, "price": "20", "title": "Snowcrash"}}]

View File

@ -1,52 +0,0 @@
### these models are for testing
from django.db import models
STATUS_CHOICES = (
(0, 'Regular'),
(1, 'Admin'),
)
class User(models.Model):
username = models.CharField(max_length=255)
first_name = models.CharField(max_length=100)
last_name = models.CharField(max_length=100)
status = models.IntegerField(choices=STATUS_CHOICES, default=0)
is_active = models.BooleanField()
favorite_books = models.ManyToManyField('Book')
def __unicode__(self):
return self.username
class Comment(models.Model):
text = models.TextField()
author = models.ForeignKey(User)
date = models.DateField()
time = models.TimeField()
def __unicode__(self):
return "%s said %s" % (self.author, self.text[:25])
class Article(models.Model):
published = models.DateTimeField()
class Book(models.Model):
title = models.CharField(max_length=100)
price = models.DecimalField(max_digits=6, decimal_places=2)
average_rating = models.FloatField()
def __unicode__(self):
return self.title
class Place(models.Model):
name = models.CharField(max_length=100)
class Meta:
abstract = True
class Restaurant(Place):
serves_pizza = models.BooleanField()

View File

@ -0,0 +1 @@
[{"pk": 1, "model": "tests.user", "fields": {"username": "alex", "status": 1, "first_name": "", "last_name": "", "favorite_books": [1, 2], "is_active": false}}, {"pk": 2, "model": "tests.user", "fields": {"username": "aaron", "status": 0, "first_name": "", "last_name": "", "favorite_books": [1, 3], "is_active": false}}, {"pk": 3, "model": "tests.user", "fields": {"username": "jacob", "status": 0, "first_name": "", "last_name": "", "favorite_books": [], "is_active": true}}, {"pk": 1, "model": "tests.comment", "fields": {"date": "2009-01-30", "text": "super awesome!", "time": "03:04:05", "author": 1}}, {"pk": 2, "model": "tests.comment", "fields": {"date": "2009-01-27", "text": "psycadelic!", "time": "05:04:03", "author": 2}}, {"pk": 3, "model": "tests.comment", "fields": {"date": "2008-12-31", "text": "funky fresh!", "time": "12:55:00", "author": 3}}, {"pk": 1, "model": "tests.book", "fields": {"average_rating": 4.7999999999999998, "price": "10", "title": "Ender's Game"}}, {"pk": 2, "model": "tests.book", "fields": {"average_rating": 4.5999999999999996, "price": "15", "title": "Rainbox Six"}}, {"pk": 3, "model": "tests.book", "fields": {"average_rating": 4.2999999999999998, "price": "20", "title": "Snowcrash"}}]

View File

@ -0,0 +1,52 @@
### these models are for testing
from django.db import models
STATUS_CHOICES = (
(0, 'Regular'),
(1, 'Admin'),
)
class User(models.Model):
username = models.CharField(max_length=255)
first_name = models.CharField(max_length=100)
last_name = models.CharField(max_length=100)
status = models.IntegerField(choices=STATUS_CHOICES, default=0)
is_active = models.BooleanField()
favorite_books = models.ManyToManyField('Book')
def __unicode__(self):
return self.username
class Comment(models.Model):
text = models.TextField()
author = models.ForeignKey(User)
date = models.DateField()
time = models.TimeField()
def __unicode__(self):
return "%s said %s" % (self.author, self.text[:25])
class Article(models.Model):
published = models.DateTimeField()
class Book(models.Model):
title = models.CharField(max_length=100)
price = models.DecimalField(max_digits=6, decimal_places=2)
average_rating = models.FloatField()
def __unicode__(self):
return self.title
class Place(models.Model):
name = models.CharField(max_length=100)
class Meta:
abstract = True
class Restaurant(Place):
serves_pizza = models.BooleanField()

View File

@ -1,6 +1,6 @@
from django.conf.urls.defaults import *
from django_filters.models import Book
from django_filters.tests.models import Book
urlpatterns = patterns('',
(r'^books/$', 'django_filters.views.object_filter', {'model': Book}),

View File

@ -5,7 +5,7 @@ from django.conf import settings
from django.test import TestCase
import django_filters
from django_filters.models import User, Comment, Book, Restaurant, Article, STATUS_CHOICES
from django_filters.tests.models import User, Comment, Book, Restaurant, Article, STATUS_CHOICES
class GenericViewTests(TestCase):
@ -98,7 +98,7 @@ filter_tests = """
>>> import django_filters
>>> from django_filters import FilterSet
>>> from django_filters.widgets import LinkWidget
>>> from django_filters.models import User, Comment, Book, STATUS_CHOICES
>>> from django_filters.tests.models import User, Comment, Book, STATUS_CHOICES
>>> call_command('loaddata', 'test_data', verbosity=0)

View File

@ -0,0 +1,11 @@
import os
DEBUG = TEMPLATE_DEBUG = True
DATABASE_ENGINE = 'sqlite3'
DATABASE_NAME = '/tmp/shorturls.db'
INSTALLED_APPS = (
'django_filters',
'django_filters.tests',
)
ROOT_URLCONF = 'django_filters.tests.test_urls'
TEMPLATE_DIRS = os.path.join(os.path.dirname(__file__), 'tests', 'templates')