diff options
Diffstat (limited to 'tests/admin_views/tests.py')
| -rw-r--r-- | tests/admin_views/tests.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py index 281084a8a1..6455b210b2 100644 --- a/tests/admin_views/tests.py +++ b/tests/admin_views/tests.py @@ -5331,6 +5331,26 @@ class DateHierarchyTests(TestCase): self.assert_non_localized_year(response, 2003) self.assert_non_localized_year(response, 2005) + def test_related_field(self): + questions_data = ( + # (posted data, number of answers), + (datetime.date(2001, 1, 30), 0), + (datetime.date(2003, 3, 15), 1), + (datetime.date(2005, 5, 3), 2), + ) + for date, answer_count in questions_data: + question = Question.objects.create(posted=date) + for i in range(answer_count): + question.answer_set.create() + + response = self.client.get(reverse('admin:admin_views_answer_changelist')) + for date, answer_count in questions_data: + link = '?question__posted__year=%d"' % (date.year,) + if answer_count > 0: + self.assertContains(response, link) + else: + self.assertNotContains(response, link) + @override_settings(ROOT_URLCONF='admin_views.urls') class AdminCustomSaveRelatedTests(TestCase): |
