diff --git a/djadmin2/tests/__init__.py b/djadmin2/tests/__init__.py index 637e13c..a5f20b0 100644 --- a/djadmin2/tests/__init__.py +++ b/djadmin2/tests/__init__.py @@ -3,3 +3,4 @@ from test_types import * from test_utils import * from test_views import * from test_core import * +from test_actions import * diff --git a/djadmin2/tests/test_actions.py b/djadmin2/tests/test_actions.py new file mode 100644 index 0000000..ff11118 --- /dev/null +++ b/djadmin2/tests/test_actions.py @@ -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) diff --git a/djadmin2/tests/test_core.py b/djadmin2/tests/test_core.py index 1d0b470..6828032 100644 --- a/djadmin2/tests/test_core.py +++ b/djadmin2/tests/test_core.py @@ -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' - )