summaryrefslogtreecommitdiff
path: root/tests/contenttypes_tests/tests.py
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2014-03-03 14:19:06 +0800
committerRussell Keith-Magee <russell@keith-magee.com>2014-03-03 14:19:06 +0800
commit57e08aa23247141db58c244f01afda52110b86b7 (patch)
treee010b8a0fd084a4d9f0ea3cedf25a9882b37b8de /tests/contenttypes_tests/tests.py
parent84207b6134dd4944f7549040a3825e90bc6fdc7e (diff)
Cleanup of contrib.contenttypes check messages.
Diffstat (limited to 'tests/contenttypes_tests/tests.py')
-rw-r--r--tests/contenttypes_tests/tests.py74
1 files changed, 15 insertions, 59 deletions
diff --git a/tests/contenttypes_tests/tests.py b/tests/contenttypes_tests/tests.py
index 5ded3268a1..fdc2917b34 100644
--- a/tests/contenttypes_tests/tests.py
+++ b/tests/contenttypes_tests/tests.py
@@ -106,10 +106,10 @@ class GenericForeignKeyTests(IsolatedModelsTestCase):
errors = TaggedItem.content_object.check()
expected = [
checks.Error(
- 'The field refers to TaggedItem.content_type field which is missing.',
+ "The GenericForeignKey content type references the non-existent field 'TaggedItem.content_type'.",
hint=None,
obj=TaggedItem.content_object,
- id='contenttypes.E005',
+ id='contenttypes.E003',
)
]
self.assertEqual(errors, expected)
@@ -124,12 +124,10 @@ class GenericForeignKeyTests(IsolatedModelsTestCase):
errors = Model.content_object.check()
expected = [
checks.Error(
- ('"content_type" field is used by a GenericForeignKey '
- 'as content type field and therefore it must be '
- 'a ForeignKey.'),
- hint=None,
+ "'Model.content_type' is not a ForeignKey.",
+ hint="GenericForeignKeys must use a ForeignKey to 'contenttypes.ContentType' as the 'content_type' field.",
obj=Model.content_object,
- id='contenttypes.E006',
+ id='contenttypes.E004',
)
]
self.assertEqual(errors, expected)
@@ -144,12 +142,10 @@ class GenericForeignKeyTests(IsolatedModelsTestCase):
errors = Model.content_object.check()
expected = [
checks.Error(
- ('"content_type" field is used by a GenericForeignKey '
- 'as content type field and therefore it must be '
- 'a ForeignKey to ContentType.'),
- hint=None,
+ "'Model.content_type' is not a ForeignKey to 'contenttypes.ContentType'.",
+ hint="GenericForeignKeys must use a ForeignKey to 'contenttypes.ContentType' as the 'content_type' field.",
obj=Model.content_object,
- id='contenttypes.E007',
+ id='contenttypes.E005',
)
]
self.assertEqual(errors, expected)
@@ -163,10 +159,10 @@ class GenericForeignKeyTests(IsolatedModelsTestCase):
errors = TaggedItem.content_object.check()
expected = [
checks.Error(
- 'The field refers to "object_id" field which is missing.',
+ "The GenericForeignKey object ID references the non-existent field 'object_id'.",
hint=None,
obj=TaggedItem.content_object,
- id='contenttypes.E001',
+ id='contenttypes.E002',
)
]
self.assertEqual(errors, expected)
@@ -181,10 +177,10 @@ class GenericForeignKeyTests(IsolatedModelsTestCase):
errors = Model.content_object_.check()
expected = [
checks.Error(
- 'Field names must not end with underscores.',
+ 'Field names must not end with an underscore.',
hint=None,
obj=Model.content_object_,
- id='contenttypes.E002',
+ id='contenttypes.E001',
)
]
self.assertEqual(errors, expected)
@@ -259,46 +255,6 @@ class GenericRelationshipTests(IsolatedModelsTestCase):
errors = Model.rel.field.check()
self.assertEqual(errors, [])
- def test_missing_content_type_field(self):
- class TaggedItem(models.Model):
- # no content_type field
- object_id = models.PositiveIntegerField()
- content_object = GenericForeignKey()
-
- class Bookmark(models.Model):
- tags = GenericRelation('TaggedItem')
-
- errors = Bookmark.tags.field.check()
- expected = [
- checks.Error(
- 'The field refers to TaggedItem.content_type field which is missing.',
- hint=None,
- obj=Bookmark.tags.field,
- id='contenttypes.E005',
- )
- ]
- self.assertEqual(errors, expected)
-
- def test_missing_object_id_field(self):
- class TaggedItem(models.Model):
- content_type = models.ForeignKey(ContentType)
- # missing object_id field
- content_object = GenericForeignKey()
-
- class Bookmark(models.Model):
- tags = GenericRelation('TaggedItem')
-
- errors = Bookmark.tags.field.check()
- expected = [
- checks.Error(
- 'The field refers to TaggedItem.object_id field which is missing.',
- hint=None,
- obj=Bookmark.tags.field,
- id='contenttypes.E003',
- )
- ]
- self.assertEqual(errors, expected)
-
def test_missing_generic_foreign_key(self):
class TaggedItem(models.Model):
content_type = models.ForeignKey(ContentType)
@@ -310,9 +266,9 @@ class GenericRelationshipTests(IsolatedModelsTestCase):
errors = Bookmark.tags.field.check()
expected = [
checks.Warning(
- ('The field defines a generic relation with the model '
- 'contenttypes_tests.TaggedItem, but the model lacks '
- 'GenericForeignKey.'),
+ ("The GenericRelation defines a relation with the model "
+ "'contenttypes_tests.TaggedItem', but that model does not have a "
+ "GenericForeignKey."),
hint=None,
obj=Bookmark.tags.field,
id='contenttypes.E004',