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
f3a2ce5a
authored
May 31, 2010
by
Alex Gaynor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make this test be transactional.
parent
b3f9995b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
12 deletions
+26
-12
taggit/tests/__init__.py
+0
-3
taggit/tests/settings.py
+1
-0
taggit/tests/tests.py
+25
-9
No files found.
taggit/tests/__init__.py
View file @
f3a2ce5a
from
taggit.tests.tests
import
(
TaggableManagerTestCase
,
TaggableFormTestCase
,
TaggableManagerDirectTestCase
,
TaggableFormDirectTestCase
,
TaggableManagerCustomPKTestCase
,
TaggableFormCustomPKTestCase
)
taggit/tests/settings.py
View file @
f3a2ce5a
DATABASE_ENGINE
=
'sqlite3'
DATABASE_ENGINE
=
'sqlite3'
INSTALLED_APPS
=
[
INSTALLED_APPS
=
[
'django.contrib.contenttypes'
,
'django.contrib.contenttypes'
,
'taggit'
,
'taggit'
,
...
...
taggit/tests/tests.py
View file @
f3a2ce5a
from
django.test
import
TestCase
from
django.test
import
TestCase
,
TransactionTestCase
from
taggit.models
import
Tag
,
TaggedItem
from
taggit.models
import
Tag
,
TaggedItem
from
taggit.tests.forms
import
FoodForm
,
DirectFoodForm
,
CustomPKFoodForm
from
taggit.tests.forms
import
FoodForm
,
DirectFoodForm
,
CustomPKFoodForm
...
@@ -7,16 +7,36 @@ from taggit.tests.models import (Food, Pet, HousePet, DirectFood, DirectPet,
...
@@ -7,16 +7,36 @@ from taggit.tests.models import (Food, Pet, HousePet, DirectFood, DirectPet,
TaggedCustomPKPet
)
TaggedCustomPKPet
)
class
BaseTaggingTest
(
TestCase
):
class
BaseTaggingTest
(
object
):
def
assert_tags_equal
(
self
,
qs
,
tags
,
sort
=
True
):
def
assert_tags_equal
(
self
,
qs
,
tags
,
sort
=
True
):
got
=
map
(
lambda
tag
:
tag
.
name
,
qs
)
got
=
map
(
lambda
tag
:
tag
.
name
,
qs
)
if
sort
:
if
sort
:
got
.
sort
()
got
.
sort
()
tags
.
sort
()
tags
.
sort
()
self
.
assertEqual
(
got
,
tags
)
self
.
assertEqual
(
got
,
tags
)
class
TaggableManagerTestCase
(
BaseTaggingTest
):
class
BaseTaggingTestCase
(
TestCase
,
BaseTaggingTest
):
pass
class
BaseTaggingTransactionTestCase
(
TransactionTestCase
,
BaseTaggingTest
):
pass
class
TagModelTestCase
(
BaseTaggingTransactionTestCase
):
food_model
=
Food
def
test_unique_slug
(
self
):
apple
=
self
.
food_model
.
objects
.
create
(
name
=
"apple"
)
apple
.
tags
.
add
(
"Red"
,
"red"
)
class
TagModelDirectTestCase
(
TagModelTestCase
):
food_model
=
DirectFood
class
TagModelCustomPKTestCase
(
TagModelTestCase
):
food_model
=
CustomPKFood
class
TaggableManagerTestCase
(
BaseTaggingTestCase
):
food_model
=
Food
food_model
=
Food
pet_model
=
Pet
pet_model
=
Pet
housepet_model
=
HousePet
housepet_model
=
HousePet
...
@@ -60,10 +80,6 @@ class TaggableManagerTestCase(BaseTaggingTest):
...
@@ -60,10 +80,6 @@ class TaggableManagerTestCase(BaseTaggingTest):
food_instance
=
self
.
food_model
()
food_instance
=
self
.
food_model
()
self
.
assertRaises
(
ValueError
,
lambda
:
food_instance
.
tags
.
all
())
self
.
assertRaises
(
ValueError
,
lambda
:
food_instance
.
tags
.
all
())
def
test_unique_slug
(
self
):
apple
=
self
.
food_model
.
objects
.
create
(
name
=
"apple"
)
apple
.
tags
.
add
(
"Red"
,
"red"
)
def
test_delete_obj
(
self
):
def
test_delete_obj
(
self
):
apple
=
self
.
food_model
.
objects
.
create
(
name
=
"apple"
)
apple
=
self
.
food_model
.
objects
.
create
(
name
=
"apple"
)
apple
.
tags
.
add
(
"red"
)
apple
.
tags
.
add
(
"red"
)
...
@@ -168,7 +184,7 @@ class TaggableManagerCustomPKTestCase(TaggableManagerTestCase):
...
@@ -168,7 +184,7 @@ class TaggableManagerCustomPKTestCase(TaggableManagerTestCase):
# tell if the instance is saved or not
# tell if the instance is saved or not
pass
pass
class
TaggableFormTestCase
(
BaseTaggingTest
):
class
TaggableFormTestCase
(
BaseTaggingTest
Case
):
form_class
=
FoodForm
form_class
=
FoodForm
food_model
=
Food
food_model
=
Food
...
...
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