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
1952c59e
authored
Mar 24, 2014
by
Nicholas Serra
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tests and test model for custom manager.
parent
4b606c75
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
3 deletions
+20
-3
tests/models.py
+8
-0
tests/tests.py
+12
-3
No files found.
tests/models.py
View file @
1952c59e
...
@@ -184,3 +184,11 @@ class Article(models.Model):
...
@@ -184,3 +184,11 @@ class Article(models.Model):
title
=
models
.
CharField
(
max_length
=
100
)
title
=
models
.
CharField
(
max_length
=
100
)
tags
=
TaggableManager
(
through
=
ArticleTaggedItem
)
tags
=
TaggableManager
(
through
=
ArticleTaggedItem
)
class
CustomManager
(
models
.
Model
):
class
Foo
(
object
):
def
__init__
(
*
args
,
**
kwargs
):
pass
tags
=
TaggableManager
(
manager
=
Foo
)
tests/tests.py
View file @
1952c59e
...
@@ -13,14 +13,14 @@ from django.utils.encoding import force_text
...
@@ -13,14 +13,14 @@ from django.utils.encoding import force_text
from
django.contrib.contenttypes.models
import
ContentType
from
django.contrib.contenttypes.models
import
ContentType
from
taggit.managers
import
TaggableManager
,
_model_name
from
taggit.managers
import
TaggableManager
,
_
TaggableManager
,
_
model_name
from
taggit.models
import
Tag
,
TaggedItem
from
taggit.models
import
Tag
,
TaggedItem
from
.forms
import
(
FoodForm
,
DirectFoodForm
,
CustomPKFoodForm
,
from
.forms
import
(
FoodForm
,
DirectFoodForm
,
CustomPKFoodForm
,
OfficialFoodForm
)
OfficialFoodForm
)
from
.models
import
(
Food
,
Pet
,
HousePet
,
DirectFood
,
DirectPet
,
from
.models
import
(
Food
,
Pet
,
HousePet
,
DirectFood
,
DirectPet
,
DirectHousePet
,
TaggedPet
,
CustomPKFood
,
CustomPKPet
,
CustomPKHousePet
,
DirectHousePet
,
TaggedPet
,
CustomPKFood
,
CustomPKPet
,
CustomPKHousePet
,
TaggedCustomPKPet
,
OfficialFood
,
OfficialPet
,
OfficialHousePet
,
TaggedCustomPKPet
,
OfficialFood
,
OfficialPet
,
OfficialHousePet
,
OfficialThroughModel
,
OfficialTag
,
Photo
,
Movie
,
Article
)
OfficialThroughModel
,
OfficialTag
,
Photo
,
Movie
,
Article
,
CustomManager
)
from
taggit.utils
import
parse_tags
,
edit_string_for_tags
from
taggit.utils
import
parse_tags
,
edit_string_for_tags
...
@@ -355,7 +355,6 @@ class TaggableManagerTestCase(BaseTaggingTestCase):
...
@@ -355,7 +355,6 @@ class TaggableManagerTestCase(BaseTaggingTestCase):
'apple'
:
set
([
'1'
,
'2'
])
'apple'
:
set
([
'1'
,
'2'
])
})
})
class
TaggableManagerDirectTestCase
(
TaggableManagerTestCase
):
class
TaggableManagerDirectTestCase
(
TaggableManagerTestCase
):
food_model
=
DirectFood
food_model
=
DirectFood
pet_model
=
DirectPet
pet_model
=
DirectPet
...
@@ -391,6 +390,16 @@ class TaggableManagerOfficialTestCase(TaggableManagerTestCase):
...
@@ -391,6 +390,16 @@ class TaggableManagerOfficialTestCase(TaggableManagerTestCase):
self
.
assertEqual
(
apple
,
self
.
food_model
.
objects
.
get
(
tags__official
=
False
))
self
.
assertEqual
(
apple
,
self
.
food_model
.
objects
.
get
(
tags__official
=
False
))
class
TaggableManagerInitializationTestCase
(
TaggableManagerTestCase
):
"""Make sure manager override defaults and sets correctly."""
food_model
=
Food
custom_manager_model
=
CustomManager
def
test_default_manager
(
self
):
self
.
assertEqual
(
self
.
food_model
.
tags
.
__class__
,
_TaggableManager
)
def
test_custom_manager
(
self
):
self
.
assertEqual
(
self
.
custom_manager_model
.
tags
.
__class__
,
CustomManager
.
Foo
)
class
TaggableFormTestCase
(
BaseTaggingTestCase
):
class
TaggableFormTestCase
(
BaseTaggingTestCase
):
form_class
=
FoodForm
form_class
=
FoodForm
...
...
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