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
|
|
|
|
|
|
|
|
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()),
|
|
|
|
u'Boolean (Either True or False)'
|
|
|
|
)
|
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()),
|
|
|
|
u'A custom field type'
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
2009-12-17 02:13:34 +08:00
|
|
|
views.get_readable_field_data_type(fields.DescriptionLackingField()),
|
|
|
|
u'Field of type: DescriptionLackingField'
|
2009-12-13 04:25:41 +08:00
|
|
|
)
|