# Path: contentful/content_type_field.py
# class ContentTypeField(object):
#     """
#     API Reference: https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/content-types
#     """
# 
#     def __init__(self, field_data):
#         self.raw = field_data
#         self.id = snake_case(field_data.get('id', ''))
#         self.name = field_data.get('name', '')
#         self.type = field_data.get('type', '')
#         self.items = field_data.get('items', {})
#         self.localized = field_data.get('localized', False)
#         self.omitted = field_data.get('omitted', False)
#         self.required = field_data.get('required', False)
#         self.disabled = field_data.get('disabled', False)
#         self._coercion = self._get_coercion()
# 
#     def coerce(self, value, **kwargs):
#         """Coerces the value to the proper type."""
# 
#         if value is None:
#             return None
#         return self._coercion.coerce(value, **kwargs)
# 
#     def _get_coercion(self):
#         """Gets the proper coercion type"""
# 
#         return globals()["{0}Field".format(self.type)](self.items)
# 
#     def __repr__(self):
#         return "<ContentTypeField[{0}] id='{1}' type='{2}'>".format(
#             self.name,
#             self.id,
#             self.type
#         )


from unittest import TestCase
from contentful.content_type_field import ContentTypeField


class ContentTypeFieldTest(TestCase):
    def test_content_type_field(self):
        content_type_field = ContentTypeField({
            "id": "name",
            "name": "Name",
            "type": "Text",
            "localized": True,
            "required": True,
            "disabled": False,
            "omitted": False
        })

        self.assertEqual(content_type_field.id, 'name')
        self.assertEqual(content_type_field.name, 'Name')
        self.assertEqual(content_type_field.type, 'Text')
        self.assertEqual(content_type_field.localized, True)
        self.assertEqual(content_type_field.omitted, False)
        self.assertEqual(content_type_field.required, True)
        self.assertEqual(content_type_field.disabled, False)
        self.assertEqual(str(content_type_field), "<ContentTypeField[Name] id='name' type='Text'>")

    def test_content_type_array_field(self):

# Path: contentful/content_type_field.py
# class ContentTypeField(object):
#     """
#     API Reference: https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/content-types
#     """
# 
#     def __init__(self, field_data):
#         self.raw = field_data
#         self.id = snake_case(field_data.get('id', ''))
#         self.name = field_data.get('name', '')
#         self.type = field_data.get('type', '')
#         self.items = field_data.get('items', {})
#         self.localized = field_data.get('localized', False)
#         self.omitted = field_data.get('omitted', False)
#         self.required = field_data.get('required', False)
#         self.disabled = field_data.get('disabled', False)
#         self._coercion = self._get_coercion()
# 
#     def coerce(self, value, **kwargs):
#         """Coerces the value to the proper type."""
# 
#         if value is None:
#             return None
#         return self._coercion.coerce(value, **kwargs)
# 
#     def _get_coercion(self):
#         """Gets the proper coercion type"""
# 
#         return globals()["{0}Field".format(self.type)](self.items)
# 
#     def __repr__(self):
#         return "<ContentTypeField[{0}] id='{1}' type='{2}'>".format(
#             self.name,
#             self.id,
#             self.type
#         )


# Path: tests/content_type_field_test.py
from unittest import TestCase
from contentful.content_type_field import ContentTypeField



class ContentTypeFieldTest(TestCase):
    def test_content_type_field(self):
        content_type_field = ContentTypeField({
            "id": "name",
            "name": "Name",
            "type": "Text",
            "localized": True,
            "required": True,
            "disabled": False,
            "omitted": False
        })

        self.assertEqual(content_type_field.id, 'name')
        self.assertEqual(content_type_field.name, 'Name')
        self.assertEqual(content_type_field.type, 'Text')
        self.assertEqual(content_type_field.localized, True)
        self.assertEqual(content_type_field.omitted, False)
        self.assertEqual(content_type_field.required, True)
        self.assertEqual(content_type_field.disabled, False)
        self.assertEqual(str(content_type_field), "<ContentTypeField[Name] id='name' type='Text'>")

    def test_content_type_array_field(self):

        content_type_field = ContentTypeField({