2009-12-17 02:13:34 +08:00
|
|
|
from django.contrib.admindocs import views
|
2009-12-13 04:25:41 +08:00
|
|
|
from django.db.models import fields as builtin_fields
|
2010-10-11 20:55:17 +08:00
|
|
|
from django.utils import unittest
|
2012-04-30 15:40:11 +08:00
|
|
|
from django.utils.translation import ugettext as _
|
2010-10-11 20:55:17 +08:00
|
|
|
|
|
|
|
import fields
|
2009-12-13 04:25:41 +08:00
|
|
|
|
2009-12-17 02:13:34 +08:00
|
|
|
|
2009-12-13 04:25:41 +08:00
|
|
|
class TestFieldType(unittest.TestCase):
|
|
|
|
def setUp(self):
|
|
|
|
pass
|
2009-12-17 02:13:34 +08:00
|
|
|
|
2009-12-13 04:25:41 +08:00
|
|
|
def test_field_name(self):
|
|
|
|
self.assertRaises(AttributeError,
|
|
|
|
views.get_readable_field_data_type, "NotAField"
|
|
|
|
)
|
2009-12-17 02:13:34 +08:00
|
|
|
|
2009-12-13 04:25:41 +08:00
|
|
|
def test_builtin_fields(self):
|
|
|
|
self.assertEqual(
|
|
|
|
views.get_readable_field_data_type(builtin_fields.BooleanField()),
|
2012-04-30 15:40:11 +08:00
|
|
|
_(u'Boolean (Either True or False)')
|
2009-12-13 04:25:41 +08:00
|
|
|
)
|
2009-12-17 02:13:34 +08:00
|
|
|
|
2009-12-13 04:25:41 +08:00
|
|
|
def test_custom_fields(self):
|
|
|
|
self.assertEqual(
|
|
|
|
views.get_readable_field_data_type(fields.CustomField()),
|
2012-04-30 15:40:11 +08:00
|
|
|
_(u'A custom field type')
|
2009-12-13 04:25:41 +08:00
|
|
|
)
|
|
|
|
self.assertEqual(
|
2009-12-17 02:13:34 +08:00
|
|
|
views.get_readable_field_data_type(fields.DescriptionLackingField()),
|
2012-04-30 15:40:11 +08:00
|
|
|
_(u'Field of type: %(field_type)s') % {
|
|
|
|
'field_type': 'DescriptionLackingField'
|
|
|
|
}
|
2009-12-13 04:25:41 +08:00
|
|
|
)
|