# 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/views.py
# class FlowEventViewSet(viewsets.ModelViewSet):
# class StatisticsViewSet(viewsets.ModelViewSet):
# class ApiAuthenticateView(APIView):
# class AerisView(LoginRequiredMixin, JsonView):
# class FlowEventMixin(LoginRequiredMixin):
# class FlowEventCreateView(FlowEventMixin, CreateView):
# class FlowEventUpdateView(FlowEventMixin, UpdateView):
# class FlowEventFormSetView(LoginRequiredMixin, ModelFormSetView):
# class CalendarView(LoginRequiredMixin, TemplateView):
# class CycleLengthFrequencyView(LoginRequiredMixin, JsonView):
# class CycleLengthHistoryView(LoginRequiredMixin, JsonView):
# class QigongCycleView(LoginRequiredMixin, JsonView):
# class StatisticsView(LoginRequiredMixin, TemplateView):
# class ProfileUpdateView(LoginRequiredMixin, UpdateView):
# class ApiInfoView(LoginRequiredMixin, TemplateView):
# class RegenerateKeyView(LoginRequiredMixin, UpdateView):
#     def get_queryset(self):
#     def perform_create(self, serializer):
#     def get_queryset(self):
#     def list(self, request, *args, **kwargs):
#     def post(self, request, *args, **kwargs):
#     def get_context_data(self, **kwargs):
#     def convert_to_user_timezone(self, timestamp):
#     def set_to_utc(self, timestamp):
#     def get_timestamp(self):
#     def is_first_day(self, timestamp):
#     def get_initial(self):
#     def get_object(self, queryset=None):
#     def get_queryset(self):
#     def get_context_data(self, **kwargs):
#     def get_context_data(self, **kwargs):
#     def get_context_data(self, **kwargs):
# def _get_level(start_date, today, cycle_length):
# def _generate_cycles(start_date, today, end_date, cycle_length):
#     def get_context_data(self, **kwargs):
#     def get_context_data(self, **kwargs):
#     def get_object(self, *args, **kwargs):
#     def get_success_url(self):
#     def get_context_data(self, **kwargs):
#     def post(self, request, *args, **kwargs):
# 
# 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',)
# 
# 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
# 
# class UserFactory(factory.DjangoModelFactory):
#     class Meta:
#         model = get_user_model()
# 
#     first_name = u'Jessamyn'
#     birth_date = pytz.utc.localize(datetime.datetime(1995, 3, 1))
#     email = factory.Sequence(lambda n: "user_%d@example.com" % n)
#     password = factory.PostGenerationMethodCall('set_password', PASSWORD)
#     last_login = pytz.utc.localize(datetime.datetime(2015, 3, 1))
# 
# PASSWORD = 'bogus_password'


import datetime
import json
import pytz
from django.core.urlresolvers import reverse
from django.http import HttpRequest, QueryDict, Http404
from django.test import Client, TestCase
from mock import patch
from rest_framework.request import Request
from rest_framework.authtoken.models import Token
from periods import models as period_models, views
from periods.serializers import FlowEventSerializer
from periods.tests.factories import FlowEventFactory, UserFactory, PASSWORD




class LoggedInUserTestCase(TestCase):

    def setUp(self):
        self.user = UserFactory()
        self.client = Client()

# 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/views.py
# class FlowEventViewSet(viewsets.ModelViewSet):
# class StatisticsViewSet(viewsets.ModelViewSet):
# class ApiAuthenticateView(APIView):
# class AerisView(LoginRequiredMixin, JsonView):
# class FlowEventMixin(LoginRequiredMixin):
# class FlowEventCreateView(FlowEventMixin, CreateView):
# class FlowEventUpdateView(FlowEventMixin, UpdateView):
# class FlowEventFormSetView(LoginRequiredMixin, ModelFormSetView):
# class CalendarView(LoginRequiredMixin, TemplateView):
# class CycleLengthFrequencyView(LoginRequiredMixin, JsonView):
# class CycleLengthHistoryView(LoginRequiredMixin, JsonView):
# class QigongCycleView(LoginRequiredMixin, JsonView):
# class StatisticsView(LoginRequiredMixin, TemplateView):
# class ProfileUpdateView(LoginRequiredMixin, UpdateView):
# class ApiInfoView(LoginRequiredMixin, TemplateView):
# class RegenerateKeyView(LoginRequiredMixin, UpdateView):
#     def get_queryset(self):
#     def perform_create(self, serializer):
#     def get_queryset(self):
#     def list(self, request, *args, **kwargs):
#     def post(self, request, *args, **kwargs):
#     def get_context_data(self, **kwargs):
#     def convert_to_user_timezone(self, timestamp):
#     def set_to_utc(self, timestamp):
#     def get_timestamp(self):
#     def is_first_day(self, timestamp):
#     def get_initial(self):
#     def get_object(self, queryset=None):
#     def get_queryset(self):
#     def get_context_data(self, **kwargs):
#     def get_context_data(self, **kwargs):
#     def get_context_data(self, **kwargs):
# def _get_level(start_date, today, cycle_length):
# def _generate_cycles(start_date, today, end_date, cycle_length):
#     def get_context_data(self, **kwargs):
#     def get_context_data(self, **kwargs):
#     def get_object(self, *args, **kwargs):
#     def get_success_url(self):
#     def get_context_data(self, **kwargs):
#     def post(self, request, *args, **kwargs):
# 
# 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',)
# 
# 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
# 
# class UserFactory(factory.DjangoModelFactory):
#     class Meta:
#         model = get_user_model()
# 
#     first_name = u'Jessamyn'
#     birth_date = pytz.utc.localize(datetime.datetime(1995, 3, 1))
#     email = factory.Sequence(lambda n: "user_%d@example.com" % n)
#     password = factory.PostGenerationMethodCall('set_password', PASSWORD)
#     last_login = pytz.utc.localize(datetime.datetime(2015, 3, 1))
# 
# PASSWORD = 'bogus_password'


# Path: periods/tests/test_views.py
import datetime
import json
import pytz
from django.core.urlresolvers import reverse
from django.http import HttpRequest, QueryDict, Http404
from django.test import Client, TestCase
from mock import patch
from rest_framework.request import Request
from rest_framework.authtoken.models import Token
from periods import models as period_models, views
from periods.serializers import FlowEventSerializer
from periods.tests.factories import FlowEventFactory, UserFactory, PASSWORD





class LoggedInUserTestCase(TestCase):

    def setUp(self):
        self.user = UserFactory()
        self.client = Client()

        self.client.login(email=self.user.email, password=PASSWORD)