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
62525c27
authored
Jul 03, 2013
by
Florian Apolloner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed query count tests on Django 1.6.
parent
5c0f6c6c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
2 deletions
+14
-2
tests/tests.py
+14
-2
No files found.
tests/tests.py
View file @
62525c27
...
...
@@ -10,6 +10,8 @@ from django.test import TestCase, TransactionTestCase
from
django.utils
import
six
from
django.utils.encoding
import
force_text
from
django.contrib.contenttypes.models
import
ContentType
from
taggit.managers
import
TaggableManager
from
taggit.models
import
Tag
,
TaggedItem
from
.forms
import
(
FoodForm
,
DirectFoodForm
,
CustomPKFoodForm
,
...
...
@@ -134,18 +136,28 @@ class TaggableManagerTestCase(BaseTaggingTestCase):
self
.
assert_tags_equal
(
self
.
food_model
.
tags
.
all
(),
[
"green"
])
def
test_add_queries
(
self
):
# Prefill content type cache:
ContentType
.
objects
.
get_for_model
(
self
.
food_model
)
apple
=
self
.
food_model
.
objects
.
create
(
name
=
"apple"
)
# 1 query to see which tags exist
# + 3 queries to create the tags.
# + 6 queries to create the intermediary things (including SELECTs, to
# make sure we don't double create.
self
.
assertNumQueries
(
10
,
apple
.
tags
.
add
,
"red"
,
"delicious"
,
"green"
)
# + 12 on Django 1.6 for save points.
queries
=
22
if
django
.
VERSION
<
(
1
,
6
):
queries
-=
12
self
.
assertNumQueries
(
queries
,
apple
.
tags
.
add
,
"red"
,
"delicious"
,
"green"
)
pear
=
self
.
food_model
.
objects
.
create
(
name
=
"pear"
)
# 1 query to see which tags exist
# + 4 queries to create the intermeidary things (including SELECTs, to
# make sure we dont't double create.
self
.
assertNumQueries
(
5
,
pear
.
tags
.
add
,
"green"
,
"delicious"
)
# + 4 on Django 1.6 for save points.
queries
=
9
if
django
.
VERSION
<
(
1
,
6
):
queries
-=
4
self
.
assertNumQueries
(
queries
,
pear
.
tags
.
add
,
"green"
,
"delicious"
)
self
.
assertNumQueries
(
0
,
pear
.
tags
.
add
)
...
...
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