# Path: periods/models.py
# def today():
#     def timezone(self):
#     def first_days(self):
#     def cycle_count(self):
#     def get_previous_period(self, previous_to):
#     def get_next_period(self, after=None):
#     def get_cache_key(self, data_type):
#     def get_cycle_lengths(self):
#     def get_sorted_cycle_lengths(self):
#     def get_full_name(self):
#     def get_short_name(self):
#     def __str__(self):
#     def choices(cls, blank=False):
#     def __str__(self):
#     def _get_ordinal_value(self, index):
#     def cycle_length_minimum(self):
#     def cycle_length_maximum(self):
#     def _get_statistics_value(self, method_name, num_values_required=1):
#     def cycle_length_mean(self):
#     def cycle_length_median(self):
#     def cycle_length_mode(self):
#     def cycle_length_standard_deviation(self):
#     def current_cycle_length(self):
#     def first_date(self):
#     def first_day(self):
#     def set_start_date_and_day(self, min_timestamp):
#     def predicted_events(self):
#     def __str__(self):
#     def get_from_server(from_date):
#     def get_for_date(cls, from_date, to_date):
# def create_auth_token(sender, instance=None, created=False, **kwargs):
# def add_to_permissions_group(sender, instance, **kwargs):
# def create_statistics(sender, instance, **kwargs):
# def update_statistics(sender, instance, **kwargs):
# class User(AbstractEmailUser):
# class LabelChoicesEnum(enum.Enum):
# class FlowLevel(LabelChoicesEnum):
# class FlowColor(LabelChoicesEnum):
# class ClotSize(LabelChoicesEnum):
# class CrampLevel(LabelChoicesEnum):
# class FlowEvent(models.Model):
# class Statistics(models.Model):
#     class Meta:
# class AerisData(models.Model):
#     SPOTTING = 0
#     LIGHT = 1
#     MEDIUM = 2
#     HEAVY = 3
#     VERY_HEAVY = 4
#     PINK = 0
#     LIGHT_RED = 1
#     RED = 2
#     DARK_RED = 3
#     BROWN = 4
#     BLACK = 5
#     SMALL = 0
#     MEDIUM = 1
#     LARGE = 2
#     SLIGHT = 0
#     MODERATE = 1
#     SEVERE = 2
# 
# Path: periods/serializers.py
# class FlowEventSerializer(serializers.ModelSerializer):
#     clots = NullableEnumField(period_models.ClotSize)
#     cramps = NullableEnumField(period_models.CrampLevel)
# 
#     class Meta:
#         model = period_models.FlowEvent
#         exclude = ('user',)
# 
# class NullableEnumField(serializers.ChoiceField):
#     """
#     Field that handles empty entries for EnumFields
#     """
# 
#     def __init__(self, enum, **kwargs):
#         super(NullableEnumField, self).__init__(enum.choices(), allow_blank=True, required=False)
# 
#     def to_internal_value(self, data):
#         if data == '' and self.allow_blank:
#             return None
# 
#         return super(NullableEnumField, self).to_internal_value(data)
# 
# Path: periods/tests/factories.py
# class FlowEventFactory(factory.DjangoModelFactory):
#     class Meta:
#         model = period_models.FlowEvent
# 
#     user = factory.SubFactory(UserFactory)
#     timestamp = pytz.utc.localize(datetime.datetime(2014, 1, 31, 17, 0, 0))
#     first_day = True


from django.test import TestCase
from rest_framework.renderers import JSONRenderer
from periods import models as period_models
from periods.serializers import FlowEventSerializer, NullableEnumField
from periods.tests.factories import FlowEventFactory



class TestNullableEnumField(TestCase):

    def test_to_internal_value_empty(self):
        field = NullableEnumField(period_models.ClotSize)

        result = field.to_internal_value('')

        self.assertIsNone(result)

    def test_to_internal_value_value(self):

# Path: periods/models.py
# def today():
#     def timezone(self):
#     def first_days(self):
#     def cycle_count(self):
#     def get_previous_period(self, previous_to):
#     def get_next_period(self, after=None):
#     def get_cache_key(self, data_type):
#     def get_cycle_lengths(self):
#     def get_sorted_cycle_lengths(self):
#     def get_full_name(self):
#     def get_short_name(self):
#     def __str__(self):
#     def choices(cls, blank=False):
#     def __str__(self):
#     def _get_ordinal_value(self, index):
#     def cycle_length_minimum(self):
#     def cycle_length_maximum(self):
#     def _get_statistics_value(self, method_name, num_values_required=1):
#     def cycle_length_mean(self):
#     def cycle_length_median(self):
#     def cycle_length_mode(self):
#     def cycle_length_standard_deviation(self):
#     def current_cycle_length(self):
#     def first_date(self):
#     def first_day(self):
#     def set_start_date_and_day(self, min_timestamp):
#     def predicted_events(self):
#     def __str__(self):
#     def get_from_server(from_date):
#     def get_for_date(cls, from_date, to_date):
# def create_auth_token(sender, instance=None, created=False, **kwargs):
# def add_to_permissions_group(sender, instance, **kwargs):
# def create_statistics(sender, instance, **kwargs):
# def update_statistics(sender, instance, **kwargs):
# class User(AbstractEmailUser):
# class LabelChoicesEnum(enum.Enum):
# class FlowLevel(LabelChoicesEnum):
# class FlowColor(LabelChoicesEnum):
# class ClotSize(LabelChoicesEnum):
# class CrampLevel(LabelChoicesEnum):
# class FlowEvent(models.Model):
# class Statistics(models.Model):
#     class Meta:
# class AerisData(models.Model):
#     SPOTTING = 0
#     LIGHT = 1
#     MEDIUM = 2
#     HEAVY = 3
#     VERY_HEAVY = 4
#     PINK = 0
#     LIGHT_RED = 1
#     RED = 2
#     DARK_RED = 3
#     BROWN = 4
#     BLACK = 5
#     SMALL = 0
#     MEDIUM = 1
#     LARGE = 2
#     SLIGHT = 0
#     MODERATE = 1
#     SEVERE = 2
# 
# Path: periods/serializers.py
# class FlowEventSerializer(serializers.ModelSerializer):
#     clots = NullableEnumField(period_models.ClotSize)
#     cramps = NullableEnumField(period_models.CrampLevel)
# 
#     class Meta:
#         model = period_models.FlowEvent
#         exclude = ('user',)
# 
# class NullableEnumField(serializers.ChoiceField):
#     """
#     Field that handles empty entries for EnumFields
#     """
# 
#     def __init__(self, enum, **kwargs):
#         super(NullableEnumField, self).__init__(enum.choices(), allow_blank=True, required=False)
# 
#     def to_internal_value(self, data):
#         if data == '' and self.allow_blank:
#             return None
# 
#         return super(NullableEnumField, self).to_internal_value(data)
# 
# Path: periods/tests/factories.py
# class FlowEventFactory(factory.DjangoModelFactory):
#     class Meta:
#         model = period_models.FlowEvent
# 
#     user = factory.SubFactory(UserFactory)
#     timestamp = pytz.utc.localize(datetime.datetime(2014, 1, 31, 17, 0, 0))
#     first_day = True


# Path: periods/tests/test_serializers.py
from django.test import TestCase
from rest_framework.renderers import JSONRenderer
from periods import models as period_models
from periods.serializers import FlowEventSerializer, NullableEnumField
from periods.tests.factories import FlowEventFactory




class TestNullableEnumField(TestCase):

    def test_to_internal_value_empty(self):
        field = NullableEnumField(period_models.ClotSize)

        result = field.to_internal_value('')

        self.assertIsNone(result)

    def test_to_internal_value_value(self):

        field = NullableEnumField(period_models.ClotSize)