implement osusers.tests.test_admin.DeleteTaskResultAdminTest

This commit is contained in:
Jan Dittberner 2014-06-01 23:05:58 +02:00
parent 6b36cc95ff
commit 0a48619f3c

View file

@ -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()