mirror of
https://github.com/jazzband/django-admin2.git
synced 2026-04-09 01:11:04 +00:00
Moving action tests to another file
This commit is contained in:
parent
f61c6648ea
commit
550c6b684b
2 changed files with 49 additions and 34 deletions
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