Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
django-taggit
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
6781567d
authored
May 21, 2010
by
Carl Meyer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
custom-pk tests
parent
15645ff6
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
6 deletions
+50
-6
taggit/tests/__init__.py
+5
-2
taggit/tests/forms.py
+5
-1
taggit/tests/models.py
+23
-0
taggit/tests/tests.py
+17
-3
No files found.
taggit/tests/__init__.py
View file @
6781567d
from
taggit.tests.tests
import
(
TaggableManagerTestCase
,
TaggableManagerDirectTestCase
,
from
taggit.tests.tests
import
(
TaggableManagerTestCase
,
TaggableFormTestCase
,
TaggableFormTestCase
,
TaggableFormDirectTestCase
)
TaggableManagerDirectTestCase
,
TaggableFormDirectTestCase
,
TaggableManagerCustomPKTestCase
,
TaggableFormCustomPKTestCase
)
taggit/tests/forms.py
View file @
6781567d
from
django
import
forms
from
django
import
forms
from
taggit.tests.models
import
Food
,
DirectFood
from
taggit.tests.models
import
Food
,
DirectFood
,
CustomPKFood
class
FoodForm
(
forms
.
ModelForm
):
class
FoodForm
(
forms
.
ModelForm
):
...
@@ -10,3 +10,7 @@ class FoodForm(forms.ModelForm):
...
@@ -10,3 +10,7 @@ class FoodForm(forms.ModelForm):
class
DirectFoodForm
(
forms
.
ModelForm
):
class
DirectFoodForm
(
forms
.
ModelForm
):
class
Meta
:
class
Meta
:
model
=
DirectFood
model
=
DirectFood
class
CustomPKFoodForm
(
forms
.
ModelForm
):
class
Meta
:
model
=
CustomPKFood
taggit/tests/models.py
View file @
6781567d
...
@@ -19,6 +19,8 @@ class Pet(models.Model):
...
@@ -19,6 +19,8 @@ class Pet(models.Model):
class
HousePet
(
Pet
):
class
HousePet
(
Pet
):
trained
=
models
.
BooleanField
()
trained
=
models
.
BooleanField
()
# test direct-tagging with custom through model
class
TaggedFood
(
TaggedItemBase
):
class
TaggedFood
(
TaggedItemBase
):
content_object
=
models
.
ForeignKey
(
'DirectFood'
)
content_object
=
models
.
ForeignKey
(
'DirectFood'
)
...
@@ -37,3 +39,24 @@ class DirectPet(models.Model):
...
@@ -37,3 +39,24 @@ class DirectPet(models.Model):
class
DirectHousePet
(
DirectPet
):
class
DirectHousePet
(
DirectPet
):
trained
=
models
.
BooleanField
()
trained
=
models
.
BooleanField
()
# test custom through model to model with custom PK
class
TaggedCustomPKFood
(
TaggedItemBase
):
content_object
=
models
.
ForeignKey
(
'CustomPKFood'
)
class
CustomPKFood
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
50
,
primary_key
=
True
)
tags
=
TaggableManager
(
through
=
TaggedCustomPKFood
)
class
TaggedCustomPKPet
(
TaggedItemBase
):
content_object
=
models
.
ForeignKey
(
'CustomPKPet'
)
class
CustomPKPet
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
50
,
primary_key
=
True
)
tags
=
TaggableManager
(
through
=
TaggedCustomPKPet
)
class
CustomPKHousePet
(
CustomPKPet
):
trained
=
models
.
BooleanField
()
taggit/tests/tests.py
View file @
6781567d
...
@@ -4,8 +4,12 @@ from contextlib import contextmanager
...
@@ -4,8 +4,12 @@ from contextlib import contextmanager
from
django.test
import
TestCase
from
django.test
import
TestCase
from
taggit.models
import
Tag
,
TaggedItem
from
taggit.models
import
Tag
,
TaggedItem
from
taggit.tests.forms
import
FoodForm
,
DirectFoodForm
from
taggit.tests.forms
import
FoodForm
,
DirectFoodForm
,
CustomPKFoodForm
from
taggit.tests.models
import
Food
,
Pet
,
HousePet
,
DirectFood
,
DirectPet
,
DirectHousePet
,
TaggedPet
from
taggit.tests.models
import
(
Food
,
Pet
,
HousePet
,
DirectFood
,
DirectPet
,
DirectHousePet
,
TaggedPet
,
CustomPKFood
,
CustomPKPet
,
CustomPKHousePet
,
TaggedCustomPKPet
)
class
BaseTaggingTest
(
TestCase
):
class
BaseTaggingTest
(
TestCase
):
...
@@ -86,7 +90,7 @@ class TaggableManagerTestCase(BaseTaggingTest):
...
@@ -86,7 +90,7 @@ class TaggableManagerTestCase(BaseTaggingTest):
def
test_delete_bulk
(
self
):
def
test_delete_bulk
(
self
):
apple
=
self
.
food_model
.
objects
.
create
(
name
=
"apple"
)
apple
=
self
.
food_model
.
objects
.
create
(
name
=
"apple"
)
kitty
=
self
.
pet_model
.
objects
.
create
(
id
=
apple
.
pk
,
name
=
"kitty"
)
kitty
=
self
.
pet_model
.
objects
.
create
(
pk
=
apple
.
pk
,
name
=
"kitty"
)
apple
.
tags
.
add
(
"red"
,
"delicious"
,
"fruit"
)
apple
.
tags
.
add
(
"red"
,
"delicious"
,
"fruit"
)
kitty
.
tags
.
add
(
"feline"
)
kitty
.
tags
.
add
(
"feline"
)
...
@@ -168,6 +172,12 @@ class TaggableManagerDirectTestCase(TaggableManagerTestCase):
...
@@ -168,6 +172,12 @@ class TaggableManagerDirectTestCase(TaggableManagerTestCase):
housepet_model
=
DirectHousePet
housepet_model
=
DirectHousePet
taggeditem_model
=
TaggedPet
taggeditem_model
=
TaggedPet
class
TaggableManagerCustomPKTestCase
(
TaggableManagerTestCase
):
food_model
=
CustomPKFood
pet_model
=
CustomPKPet
housepet_model
=
CustomPKHousePet
taggeditem_model
=
TaggedCustomPKPet
class
TaggableFormTestCase
(
BaseTaggingTest
):
class
TaggableFormTestCase
(
BaseTaggingTest
):
form_class
=
FoodForm
form_class
=
FoodForm
...
@@ -198,3 +208,7 @@ class TaggableFormTestCase(BaseTaggingTest):
...
@@ -198,3 +208,7 @@ class TaggableFormTestCase(BaseTaggingTest):
class
TaggableFormDirectTestCase
(
TaggableFormTestCase
):
class
TaggableFormDirectTestCase
(
TaggableFormTestCase
):
form_class
=
DirectFoodForm
form_class
=
DirectFoodForm
food_model
=
DirectFood
food_model
=
DirectFood
class
TaggableFormCustomPKTestCase
(
TaggableFormTestCase
):
form_class
=
CustomPKFoodForm
food_model
=
CustomPKFood
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment