mirror of
https://github.com/jazzband/django-admin2.git
synced 2026-03-16 22:20:24 +00:00
45 lines
1.1 KiB
Python
45 lines
1.1 KiB
Python
from django.test import TestCase
|
|
|
|
from ..core import Admin2
|
|
from ..actions import get_description
|
|
from .models import Thing
|
|
|
|
|
|
class TestAction:
|
|
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,
|
|
])
|
|
self.assertEqual(
|
|
get_description(
|
|
self.admin2.registry[Thing].list_actions[0]
|
|
),
|
|
'Delete selected items'
|
|
)
|
|
self.assertEqual(
|
|
get_description(
|
|
self.admin2.registry[Thing].list_actions[1]
|
|
),
|
|
'Test Action Class'
|
|
)
|
|
self.assertEqual(
|
|
get_description(
|
|
self.admin2.registry[Thing].list_actions[2]
|
|
),
|
|
'Test function'
|
|
)
|
|
self.admin2.registry[Thing].list_actions.remove(TestAction)
|
|
self.admin2.registry[Thing].list_actions.remove(test_function)
|