diff options
author | zsoldosp <peter.zsoldos@gmail.com> | 2014-05-16 11:55:09 +0200 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2014-06-25 15:39:56 -0400 |
commit | 7e2c804c9417617934cd731a4537719a1bd8d985 (patch) | |
tree | ec0d0429309ffb31312fc2a8e4752cfcfd442841 /tests/dates | |
parent | 77c0a904cbb2ff144dc42deac4e9fbca0c370f1b (diff) | |
download | django-7e2c804c9417617934cd731a4537719a1bd8d985.tar.gz |
Split tests.basic.ModelTests in several tests; refs #18586.
Diffstat (limited to 'tests/dates')
-rw-r--r-- | tests/dates/tests.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/dates/tests.py b/tests/dates/tests.py index c2a8d82e37..2177ad046e 100644 --- a/tests/dates/tests.py +++ b/tests/dates/tests.py @@ -2,7 +2,9 @@ from __future__ import unicode_literals import datetime +from django.db.models.fields import FieldDoesNotExist from django.test import TestCase +from django.utils import six from .models import Article, Comment, Category @@ -81,3 +83,40 @@ class DatesTests(TestCase): ], lambda d: d, ) + + def test_dates_fails_when_no_arguments_are_provided(self): + self.assertRaises( + TypeError, + Article.objects.dates, + ) + + def test_dates_fails_when_given_invalid_field_argument(self): + six.assertRaisesRegex( + self, + FieldDoesNotExist, + "Article has no field named 'invalid_field'", + Article.objects.dates, + "invalid_field", + "year", + ) + + def test_dates_fails_when_given_invalid_kind_argument(self): + six.assertRaisesRegex( + self, + AssertionError, + "'kind' must be one of 'year', 'month' or 'day'.", + Article.objects.dates, + "pub_date", + "bad_kind", + ) + + def test_dates_fails_when_given_invalid_order_argument(self): + six.assertRaisesRegex( + self, + AssertionError, + "'order' must be either 'ASC' or 'DESC'.", + Article.objects.dates, + "pub_date", + "year", + order="bad order", + ) |