summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-10-14 02:13:51 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-10-14 02:13:51 +0000
commitb47231ee3e164855590b231d6092e54938d6ae53 (patch)
treecba6187863e13b08c4c1b5fb909378992e488559 /tests
parente9f1f5046147fc0d1a9f3a24bfa6607ef0742e80 (diff)
querset-refactor: Fixed a bunch of little things as a result of working on the
tests. All of modeltests/ now pass. This includes a fix to modeltests/signals/ (in the post_delete signal testing), which I'm sure was incorrect previously. git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6489 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/modeltests/many_to_one/models.py8
-rw-r--r--tests/modeltests/or_lookups/models.py8
-rw-r--r--tests/modeltests/signals/models.py4
3 files changed, 9 insertions, 11 deletions
diff --git a/tests/modeltests/many_to_one/models.py b/tests/modeltests/many_to_one/models.py
index d5d07a1e21..85365e2bc3 100644
--- a/tests/modeltests/many_to_one/models.py
+++ b/tests/modeltests/many_to_one/models.py
@@ -145,18 +145,18 @@ False
[<Article: John's second story>, <Article: This is a test>]
# The underlying query only makes one join when a related table is referenced twice.
->>> query = Article.objects.filter(reporter__first_name__exact='John', reporter__last_name__exact='Smith')
->>> null, sql, null = query._get_sql_clause()
+>>> queryset = Article.objects.filter(reporter__first_name__exact='John', reporter__last_name__exact='Smith')
+>>> sql = queryset.query.as_sql()[0]
>>> sql.count('INNER JOIN')
1
# The automatically joined table has a predictable name.
->>> Article.objects.filter(reporter__first_name__exact='John').extra(where=["many_to_one_article__reporter.last_name='Smith'"])
+>>> Article.objects.filter(reporter__first_name__exact='John').extra(where=["many_to_one_reporter.last_name='Smith'"])
[<Article: John's second story>, <Article: This is a test>]
# And should work fine with the unicode that comes out of
# newforms.Form.cleaned_data
->>> Article.objects.filter(reporter__first_name__exact='John').extra(where=["many_to_one_article__reporter.last_name='%s'" % u'Smith'])
+>>> Article.objects.filter(reporter__first_name__exact='John').extra(where=["many_to_one_reporter.last_name='%s'" % u'Smith'])
[<Article: John's second story>, <Article: This is a test>]
# Find all Articles for the Reporter whose ID is 1.
diff --git a/tests/modeltests/or_lookups/models.py b/tests/modeltests/or_lookups/models.py
index ee2cfd2b95..5dc8351054 100644
--- a/tests/modeltests/or_lookups/models.py
+++ b/tests/modeltests/or_lookups/models.py
@@ -4,11 +4,9 @@
To perform an OR lookup, or a lookup that combines ANDs and ORs,
combine QuerySet objects using & and | operators.
-Alternatively, use positional arguments, and pass one or more expressions
-of clauses using the variable ``django.db.models.Q`` (or any object with
-a get_sql method).
-
-
+Alternatively, use positional arguments, and pass one or more expressions of
+clauses using the variable ``django.db.models.Q`` (or any object with an
+add_to_query method).
"""
from django.db import models
diff --git a/tests/modeltests/signals/models.py b/tests/modeltests/signals/models.py
index 1fb73828bb..d41142135e 100644
--- a/tests/modeltests/signals/models.py
+++ b/tests/modeltests/signals/models.py
@@ -54,7 +54,7 @@ Is updated
pre_delete signal, Tom Smith
instance.id is not None: True
post_delete signal, Tom Smith
-instance.id is None: False
+instance.id is None: True
>>> p2 = Person(first_name='James', last_name='Jones')
>>> p2.id = 99999
@@ -73,7 +73,7 @@ Is created
pre_delete signal, James Jones
instance.id is not None: True
post_delete signal, James Jones
-instance.id is None: False
+instance.id is None: True
>>> Person.objects.all()
[<Person: James Jones>]