Merge pull request #254 from ifosch/test-improvements

Actions test isolated
This commit is contained in:
Daniel Greenfeld 2013-07-06 05:56:50 -07:00
commit 32bcce562e
3 changed files with 50 additions and 34 deletions

View file

@ -3,3 +3,4 @@ from test_types import *
from test_utils import *
from test_views import *
from test_core import *
from test_actions import *

View 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)

View file

@ -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'
)