# Path: likert_field/models.py
# class LikertField(models.IntegerField):
#     """A Likert field is simply stored as an IntegerField"""
# 
#     description = _('Likert item field')
# 
#     def __init__(self, *args, **kwargs):
#         """
#         LikertField stores items with no answer as NULL
# 
#         By default responses are optional, so 'blank' is True
#         """
#         if kwargs.get('null', True):
#             kwargs['null'] = True
# 
#         if kwargs.get('blank', True):
#             kwargs['blank'] = True
# 
#         super(LikertField, self).__init__(*args, **kwargs)
# 
#     def __str__(self):
#         return "%s" % force_text(self.description)
# 
#     def get_prep_value(self, value):
#         """
#         Perform preliminary non-db specific value checks and conversions.
# 
#         The field expects a number as a string (ie. '2'). Unscored fields are
#         empty strings and are stored as NULL
#         """
#         if value is None:
#             return None
# 
#         if isinstance(value, string_types) and len(value) == 0:
#             return None
# 
#         value = int(value)
#         if value < 0:
#             value = 0
# 
#         return value
# 
#     def formfield(self, **kwargs):
#         defaults = {
#             'min_value': 0,
#             'form_class': forms.LikertFormField
#         }
#         defaults.update(kwargs)
#         return super(LikertField, self).formfield(**defaults)
# 
# Path: likert_field/forms.py
# class LikertFormField(fields.IntegerField):
#     def __init__(self, min_value=0, *args, **kwargs):


from django.db.models.fields import Field
from django.test import SimpleTestCase
from django.utils.six.moves import xrange
from likert_field.models import LikertField
from likert_field import forms
        self.assertTrue(item.blank)

    def test_blank_settable(self):
        item = LikertField(blank=False)
        self.assertFalse(item.blank)

    def test_get_prep_value_int(self):
        item = LikertField()
        for value in xrange(1, 50+1):
            self.assertIsInstance(item.get_prep_value(value), int)

    def test_get_prep_value_strings(self):
        item = LikertField()
        for value in xrange(1, 50+1):
            self.assertIsInstance(item.get_prep_value(str(value)), int)

    def test_get_prep_value_negative_int(self):
        item = LikertField()
        self.assertIsInstance(item.get_prep_value(-1), int)
        self.assertEqual(item.get_prep_value(-1), 0)

    def test_get_prep_value_empty_string(self):
        item = LikertField()
        self.assertTrue(item.get_prep_value('') is None)

    def test_get_prep_value_null(self):
        item = LikertField()
        self.assertTrue(item.get_prep_value(None) is None)

    def test_formfield(self):

# Path: likert_field/models.py
# class LikertField(models.IntegerField):
#     """A Likert field is simply stored as an IntegerField"""
# 
#     description = _('Likert item field')
# 
#     def __init__(self, *args, **kwargs):
#         """
#         LikertField stores items with no answer as NULL
# 
#         By default responses are optional, so 'blank' is True
#         """
#         if kwargs.get('null', True):
#             kwargs['null'] = True
# 
#         if kwargs.get('blank', True):
#             kwargs['blank'] = True
# 
#         super(LikertField, self).__init__(*args, **kwargs)
# 
#     def __str__(self):
#         return "%s" % force_text(self.description)
# 
#     def get_prep_value(self, value):
#         """
#         Perform preliminary non-db specific value checks and conversions.
# 
#         The field expects a number as a string (ie. '2'). Unscored fields are
#         empty strings and are stored as NULL
#         """
#         if value is None:
#             return None
# 
#         if isinstance(value, string_types) and len(value) == 0:
#             return None
# 
#         value = int(value)
#         if value < 0:
#             value = 0
# 
#         return value
# 
#     def formfield(self, **kwargs):
#         defaults = {
#             'min_value': 0,
#             'form_class': forms.LikertFormField
#         }
#         defaults.update(kwargs)
#         return super(LikertField, self).formfield(**defaults)
# 
# Path: likert_field/forms.py
# class LikertFormField(fields.IntegerField):
#     def __init__(self, min_value=0, *args, **kwargs):


# Path: test_suite/test_models.py
from django.db.models.fields import Field
from django.test import SimpleTestCase
from django.utils.six.moves import xrange
from likert_field.models import LikertField
from likert_field import forms

        self.assertTrue(item.blank)

    def test_blank_settable(self):
        item = LikertField(blank=False)
        self.assertFalse(item.blank)

    def test_get_prep_value_int(self):
        item = LikertField()
        for value in xrange(1, 50+1):
            self.assertIsInstance(item.get_prep_value(value), int)

    def test_get_prep_value_strings(self):
        item = LikertField()
        for value in xrange(1, 50+1):
            self.assertIsInstance(item.get_prep_value(str(value)), int)

    def test_get_prep_value_negative_int(self):
        item = LikertField()
        self.assertIsInstance(item.get_prep_value(-1), int)
        self.assertEqual(item.get_prep_value(-1), 0)

    def test_get_prep_value_empty_string(self):
        item = LikertField()
        self.assertTrue(item.get_prep_value('') is None)

    def test_get_prep_value_null(self):
        item = LikertField()
        self.assertTrue(item.get_prep_value(None) is None)

    def test_formfield(self):

        item = LikertField()