2013-07-06 12:17:04 +00:00
|
|
|
from django.test import TestCase
|
|
|
|
|
|
|
|
|
|
from ..core import Admin2
|
|
|
|
|
from ..actions import get_description
|
2016-05-20 08:54:42 +00:00
|
|
|
from .models import Thing
|
2013-07-06 12:17:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestAction(object):
|
|
|
|
|
description = "Test Action Class"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_function():
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ActionTest(TestCase):
|
|
|
|
|
def setUp(self):
|
|
|
|
|
self.admin2 = Admin2()
|
|
|
|
|
|
|
|
|
|
def test_action_description(self):
|
|
|
|
|
self.admin2.register(Thing)
|
|
|
|
|
self.admin2.registry[Thing].list_actions.extend([
|
|
|
|
|
TestAction,
|
|
|
|
|
test_function,
|
2016-05-07 20:59:15 +00:00
|
|
|
])
|
2018-10-23 08:32:57 +00:00
|
|
|
self.assertEqual(
|
2013-07-06 12:17:04 +00:00
|
|
|
get_description(
|
|
|
|
|
self.admin2.registry[Thing].list_actions[0]
|
2016-05-07 20:59:15 +00:00
|
|
|
),
|
2013-07-06 12:17:04 +00:00
|
|
|
'Delete selected items'
|
2016-05-07 20:59:15 +00:00
|
|
|
)
|
2018-10-23 08:32:57 +00:00
|
|
|
self.assertEqual(
|
2013-07-06 12:17:04 +00:00
|
|
|
get_description(
|
|
|
|
|
self.admin2.registry[Thing].list_actions[1]
|
2016-05-07 20:59:15 +00:00
|
|
|
),
|
2013-07-06 12:17:04 +00:00
|
|
|
'Test Action Class'
|
2016-05-07 20:59:15 +00:00
|
|
|
)
|
2018-10-23 08:32:57 +00:00
|
|
|
self.assertEqual(
|
2013-07-06 12:17:04 +00:00
|
|
|
get_description(
|
|
|
|
|
self.admin2.registry[Thing].list_actions[2]
|
2016-05-07 20:59:15 +00:00
|
|
|
),
|
2013-07-06 12:17:04 +00:00
|
|
|
'Test function'
|
2016-05-07 20:59:15 +00:00
|
|
|
)
|
2013-07-06 12:17:04 +00:00
|
|
|
self.admin2.registry[Thing].list_actions.remove(TestAction)
|
|
|
|
|
self.admin2.registry[Thing].list_actions.remove(test_function)
|