From 0a48619f3c6ea0db9921f4e1e4b8192b36b14349 Mon Sep 17 00:00:00 2001 From: Jan Dittberner Date: Sun, 1 Jun 2014 23:05:58 +0200 Subject: [PATCH] implement osusers.tests.test_admin.DeleteTaskResultAdminTest --- gnuviechadmin/osusers/tests/test_admin.py | 26 +++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/gnuviechadmin/osusers/tests/test_admin.py b/gnuviechadmin/osusers/tests/test_admin.py index fe2faaa..12091ba 100644 --- a/gnuviechadmin/osusers/tests/test_admin.py +++ b/gnuviechadmin/osusers/tests/test_admin.py @@ -6,10 +6,12 @@ from django.test.utils import override_settings from mock import patch, Mock from osusers.models import ( + DeleteTaskResult, Group, User, ) from osusers.admin import ( + DeleteTaskResultAdmin, GroupAdmin, PASSWORD_MISMATCH_ERROR, UserAdmin, @@ -135,3 +137,27 @@ class GroupAdminTest(TestCase): self.assertEqual(len(inlines), len(GroupAdmin.inlines)) for index in range(len(inlines)): self.assertIsInstance(inlines[index], GroupAdmin.inlines[index]) + + +class DeleteTaskResultAdminTest(TestCase): + def setUp(self): + site = AdminSite() + self.dtradmin = DeleteTaskResultAdmin(DeleteTaskResult, site) + super(DeleteTaskResultAdminTest, self).setUp() + + def test_has_add_permission_returns_false_without_object(self): + self.assertFalse( + self.dtradmin.has_add_permission(Mock(name='request'))) + + def test_has_add_permission_returns_false_with_object(self): + self.assertFalse( + self.dtradmin.has_add_permission(Mock(name='request'), + Mock(name='test'))) + + def test_get_queryset_calls_update_taskstatus(self): + with patch('osusers.admin.admin.ModelAdmin.get_queryset') as mock: + entrymock = Mock(name='entry') + mock.return_value = [entrymock] + requestmock = Mock(name='request') + self.dtradmin.get_queryset(requestmock) + entrymock.update_taskstatus.assert_calledwith()