mirror of
https://github.com/jazzband/django-admin2.git
synced 2026-03-17 06:30:25 +00:00
Merge pull request #254 from ifosch/test-improvements
Actions test isolated
This commit is contained in:
commit
32bcce562e
3 changed files with 50 additions and 34 deletions
|
|
@ -3,3 +3,4 @@ from test_types import *
|
|||
from test_utils import *
|
||||
from test_views import *
|
||||
from test_core import *
|
||||
from test_actions import *
|
||||
|
|
|
|||
49
djadmin2/tests/test_actions.py
Normal file
49
djadmin2/tests/test_actions.py
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
from django.db import models
|
||||
from django.test import TestCase
|
||||
|
||||
from ..core import Admin2
|
||||
from ..actions import get_description
|
||||
|
||||
|
||||
class Thing(models.Model):
|
||||
pass
|
||||
|
||||
|
||||
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,
|
||||
])
|
||||
self.assertEquals(
|
||||
get_description(
|
||||
self.admin2.registry[Thing].list_actions[0]
|
||||
),
|
||||
'Delete selected items'
|
||||
)
|
||||
self.assertEquals(
|
||||
get_description(
|
||||
self.admin2.registry[Thing].list_actions[1]
|
||||
),
|
||||
'Test Action Class'
|
||||
)
|
||||
self.assertEquals(
|
||||
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)
|
||||
|
|
@ -4,21 +4,12 @@ from django.test import TestCase
|
|||
|
||||
from ..types import ModelAdmin2
|
||||
from ..core import Admin2
|
||||
from ..actions import get_description
|
||||
|
||||
|
||||
class Thing(models.Model):
|
||||
pass
|
||||
|
||||
|
||||
class TestAction(object):
|
||||
description = "Test Action Class"
|
||||
|
||||
|
||||
def test_function():
|
||||
pass
|
||||
|
||||
|
||||
class Admin2Test(TestCase):
|
||||
def setUp(self):
|
||||
self.admin2 = Admin2()
|
||||
|
|
@ -42,28 +33,3 @@ class Admin2Test(TestCase):
|
|||
def test_get_urls(self):
|
||||
self.admin2.register(Thing)
|
||||
self.assertEquals(8, len(self.admin2.get_urls()))
|
||||
|
||||
def test_action_description(self):
|
||||
self.admin2.register(Thing)
|
||||
self.admin2.registry[Thing].list_actions.extend([
|
||||
TestAction,
|
||||
test_function
|
||||
])
|
||||
self.assertEquals(
|
||||
get_description(
|
||||
self.admin2.registry[Thing].list_actions[0]
|
||||
),
|
||||
'Delete selected items'
|
||||
)
|
||||
self.assertEquals(
|
||||
get_description(
|
||||
self.admin2.registry[Thing].list_actions[1]
|
||||
),
|
||||
'Test Action Class'
|
||||
)
|
||||
self.assertEquals(
|
||||
get_description(
|
||||
self.admin2.registry[Thing].list_actions[2]
|
||||
),
|
||||
'Test function'
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue