magic-removal: Updated unit tests to use objects.all()

git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2190 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2006-01-30 22:44:05 +00:00
parent ad211a7cc3
commit b349e42aac
8 changed files with 20 additions and 20 deletions

View File

@ -13,7 +13,7 @@ class Article(models.Model):
API_TESTS = """
# No articles are in the system yet.
>>> list(Article.objects)
>>> list(Article.objects.all())
[]
# Create an Article.
@ -40,7 +40,7 @@ datetime.datetime(2005, 7, 28, 0, 0)
# Listing objects displays all the articles in the database. Note that the article
# is represented by "<Article object>", because we haven't given the Article
# model a __repr__() method.
>>> list(Article.objects)
>>> list(Article.objects.all())
[<Article object>]
# Django provides a rich database lookup API that's entirely driven by
@ -222,9 +222,9 @@ AssertionError: 'order' must be either 'ASC' or 'DESC'.
1
# You can get items using index and slice notation.
>>> Article.objects[0]
>>> Article.objects.all()[0]
<Article object>
>>> Article.objects[1:2]
>>> Article.objects.all()[1:2]
[<Article object>, <Article object>]
>>> s3 = Article.objects.filter(id__exact=3)
>>> (s1 | s2 | s3)[::2]
@ -232,7 +232,7 @@ AssertionError: 'order' must be either 'ASC' or 'DESC'.
# An Article instance doesn't have access to the "objects" attribute.
# That is only available as a class method.
>>> list(a7.objects)
>>> a7.objects.all()
Traceback (most recent call last):
...
AttributeError: Manager isn't accessible via Article instances

View File

@ -23,7 +23,7 @@ API_TESTS = """
>>> p.id
1
>>> list(Person.objects)
>>> list(Person.objects.all())
[John Smith]
>>> list(Person.objects.filter(first_name__exact='John'))

View File

@ -29,12 +29,12 @@ class Business(models.Model):
API_TESTS = """
>>> dan = Employee(employee_code='ABC123', first_name='Dan', last_name='Jones')
>>> dan.save()
>>> list(Employee.objects)
>>> list(Employee.objects.all())
[Dan Jones]
>>> fran = Employee(employee_code='XYZ456', first_name='Fran', last_name='Bones')
>>> fran.save()
>>> list(Employee.objects)
>>> list(Employee.objects.all())
[Fran Bones, Dan Jones]
>>> Employee.objects.get(pk='ABC123')

View File

@ -32,9 +32,9 @@ API_TESTS = """
>>> m1 = man.save(data)
# Verify it worked.
>>> list(Musician.objects)
>>> list(Musician.objects.all())
[Ella Fitzgerald]
>>> [m1] == list(Musician.objects)
>>> [m1] == list(Musician.objects.all())
True
# Attempt to add a Musician without a first_name.
@ -66,7 +66,7 @@ True
>>> a1 = man.save(data)
# Verify it worked.
>>> list(Album.objects)
>>> list(Album.objects.all())
[Ella and Basie]
>>> Album.objects.get().musician
Ella Fitzgerald
@ -79,7 +79,7 @@ Ella Fitzgerald
>>> a2 = man.save(data)
# Verify it worked.
>>> list(Album.objects.filter(order_by=['name']))
>>> list(Album.objects.order_by('name'))
[Ella and Basie, Ultimate Ella]
>>> a2 = Album.objects.get(pk=2)
>>> a2

View File

@ -96,7 +96,7 @@ True
# If we delete a Publication, its Articles won't be able to access it.
>>> p1.delete()
>>> list(Publication.objects)
>>> list(Publication.objects.all())
[Science News, Science Weekly]
>>> a1 = Article.objects.get(pk=1)
>>> list(a1.publication_set)
@ -104,7 +104,7 @@ True
# If we delete an Article, its Publications won't be able to access it.
>>> a2.delete()
>>> list(Article.objects)
>>> list(Article.objects.all())
[Django lets you build Web apps easily]
>>> list(p1.article_set.order_by('headline'))
[Django lets you build Web apps easily]

View File

@ -56,12 +56,12 @@ Traceback (most recent call last):
DoesNotExist: Restaurant does not exist for {'place__id__exact': ...}
# Restaurant.objects.get_list() just returns the Restaurants, not the Places.
>>> list(Restaurant.objects)
>>> list(Restaurant.objects.all())
[Demon Dogs the restaurant]
# Place.objects.get_list() returns all Places, regardless of whether they have
# Restaurants.
>>> list(Place.objects.filter(order_by=['name']))
>>> list(Place.objects.order_by('name'))
[Ace Hardware the place, Demon Dogs the place]
>>> Restaurant.objects.get(place__id__exact=1)

View File

@ -36,9 +36,9 @@ API_TESTS = """
>>> a4 = Article(headline='Article 4', pub_date=datetime(2005, 7, 28))
>>> a4.save()
# By default, articles.get_list() orders by pub_date descending, then
# By default, Article.objects.all() orders by pub_date descending, then
# headline ascending.
>>> list(Article.objects)
>>> list(Article.objects.all())
[Article 4, Article 2, Article 3, Article 1]
# Override ordering with order_by, which is in the same format as the ordering

View File

@ -30,13 +30,13 @@ API_TESTS = """
Before save
After save
>>> list(Person.objects)
>>> list(Person.objects.all())
[John Smith]
>>> p1.delete()
Before deletion
After deletion
>>> list(Person.objects)
>>> list(Person.objects.all())
[]
"""