Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added model unit tests for year, month and day lookup. Refs #659

git-svn-id: http://code.djangoproject.com/svn/django/trunk@1033 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 3226127aa29c498921f7a7e4209de229d253d21f 1 parent 546e368
@adrianholovaty adrianholovaty authored
Showing with 16 additions and 0 deletions.
  1. +16 −0 tests/testapp/models/basic.py
View
16 tests/testapp/models/basic.py
@@ -51,6 +51,17 @@ class Article(meta.Model):
<Article object>
>>> articles.get_object(pub_date__year=2005)
<Article object>
+>>> articles.get_object(pub_date__year=2005, pub_date__month=7)
+<Article object>
+>>> articles.get_object(pub_date__year=2005, pub_date__month=7, pub_date__day=28)
+<Article object>
+
+>>> articles.get_list(pub_date__year=2005)
+[<Article object>]
+>>> articles.get_list(pub_date__year=2004)
+[]
+>>> articles.get_list(pub_date__year=2005, pub_date__month=7)
+[<Article object>]
# Django raises an ArticleDoesNotExist exception for get_object()
>>> articles.get_object(id__exact=2)
@@ -58,6 +69,11 @@ class Article(meta.Model):
...
ArticleDoesNotExist: Article does not exist for {'id__exact': 2}
+>>> articles.get_object(pub_date__year=2005, pub_date__month=8)
+Traceback (most recent call last):
+ ...
+ArticleDoesNotExist: Article does not exist for ...
+
# Lookup by a primary key is the most common case, so Django provides a
# shortcut for primary-key exact lookups.
# The following is identical to articles.get_object(id__exact=1).
Please sign in to comment.
Something went wrong with that request. Please try again.