From 3226127aa29c498921f7a7e4209de229d253d21f Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Tue, 1 Nov 2005 00:40:32 +0000 Subject: [PATCH] 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 --- tests/testapp/models/basic.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/testapp/models/basic.py b/tests/testapp/models/basic.py index ebd784137a..ad2a8cb862 100644 --- a/tests/testapp/models/basic.py +++ b/tests/testapp/models/basic.py @@ -51,6 +51,17 @@ datetime.datetime(2005, 7, 28, 0, 0)
>>> articles.get_object(pub_date__year=2005)
+>>> articles.get_object(pub_date__year=2005, pub_date__month=7) +
+>>> articles.get_object(pub_date__year=2005, pub_date__month=7, pub_date__day=28) +
+ +>>> articles.get_list(pub_date__year=2005) +[
] +>>> articles.get_list(pub_date__year=2004) +[] +>>> articles.get_list(pub_date__year=2005, pub_date__month=7) +[
] # Django raises an ArticleDoesNotExist exception for get_object() >>> articles.get_object(id__exact=2) @@ -58,6 +69,11 @@ Traceback (most recent call last): ... 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).