Skip to content

Commit

Permalink
testing composite key for Django 1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Simone Federici committed Apr 3, 2013
1 parent 0cc417a commit 01b8b7a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
class TaggedItem(models.Model):
"""A tag on an item."""
tag = models.SlugField()
content_type = models.ForeignKey(ContentType)
content_type = models.ForeignKey(ContentType, related_name="ct")
object_id = models.PositiveIntegerField()

content_object = generic.GenericForeignKey()
Expand All @@ -43,10 +43,10 @@ class Comparison(models.Model):
"""
comparative = models.CharField(max_length=50)

content_type1 = models.ForeignKey(ContentType, related_name="comparative1_set")
content_type1 = models.ForeignKey(ContentType, related_name="comparative11_set")
object_id1 = models.PositiveIntegerField()

content_type2 = models.ForeignKey(ContentType, related_name="comparative2_set")
content_type2 = models.ForeignKey(ContentType, related_name="comparative22_set")
object_id2 = models.PositiveIntegerField()

first_obj = generic.GenericForeignKey(ct_field="content_type1", fk_field="object_id1")
Expand Down
5 changes: 4 additions & 1 deletion djangotests/cruntests.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@


CONTRIB_DIR_NAME = 'django.contrib'
MODEL_TESTS_DIR_NAME = 'composite_modeltests'
MODEL_TESTS_DIR_NAME = 'modeltests'
REGRESSION_TESTS_DIR_NAME = 'regressiontests'
COMPOSITE_TESTS_DIR_NAME = 'composite_modeltests'

TEST_TEMPLATE_DIR = 'templates'

RUNTESTS_DIR = os.path.dirname(__file__)
CONTRIB_DIR = os.path.dirname(contrib.__file__)
MODEL_TEST_DIR = os.path.join(RUNTESTS_DIR, MODEL_TESTS_DIR_NAME)
REGRESSION_TEST_DIR = os.path.join(RUNTESTS_DIR, REGRESSION_TESTS_DIR_NAME)
COMPOSITE_TEST_DIR = os.path.join(RUNTESTS_DIR, COMPOSITE_TESTS_DIR_NAME)
TEMP_DIR = tempfile.mkdtemp(prefix='django_')
os.environ['DJANGO_TEST_TEMP_DIR'] = TEMP_DIR

Expand Down Expand Up @@ -51,6 +53,7 @@ def get_test_modules():
modules = []
for loc, dirpath in (
(MODEL_TESTS_DIR_NAME, MODEL_TEST_DIR),
(COMPOSITE_TESTS_DIR_NAME, COMPOSITE_TEST_DIR),
(REGRESSION_TESTS_DIR_NAME, REGRESSION_TEST_DIR),
(CONTRIB_DIR_NAME, CONTRIB_DIR)):
for f in os.listdir(dirpath):
Expand Down

0 comments on commit 01b8b7a

Please sign in to comment.