def setUp(self):
     self.command = notify_upcoming_period.Command()
     flow_event = FlowEventFactory()
     self.user = flow_event.user
     FlowEventFactory(user=self.user,
                      timestamp=pytz.utc.localize(
                          datetime.datetime(2014, 2, 28)))
예제 #2
0
 def setUp(self):
     super(TestStatisticsViewsWithData, self).setUp()
     FlowEventFactory(user=self.user)
     FlowEventFactory(user=self.user,
                      timestamp=pytz.utc.localize(
                          datetime.datetime(2014, 2, 28)))
     FlowEventFactory(user=self.user,
                      timestamp=pytz.utc.localize(
                          datetime.datetime(2014, 3, 26)))
     self.url_path = reverse('statistics')
예제 #3
0
    def setUp(self):
        self.user = UserFactory()
        self.basic_user = UserFactory.build(first_name='')

        self.period = FlowEventFactory()
        FlowEventFactory(user=self.period.user,
                         timestamp=TIMEZONE.localize(
                             datetime.datetime(2014, 2, 27)))
        FlowEventFactory(user=self.period.user,
                         timestamp=TIMEZONE.localize(
                             datetime.datetime(2014, 3, 24)))
예제 #4
0
    def setUp(self):
        self.view_set = views.StatisticsViewSet()
        self.view_set.format_kwarg = ''

        self.period = FlowEventFactory()
        self.period2 = FlowEventFactory(
            timestamp=pytz.utc.localize(datetime.datetime(2014, 2, 28)))

        self.request = Request(HttpRequest())
        self.request.__setattr__('user', self.period.user)
        self.view_set.request = self.request
예제 #5
0
    def test_update_statistics_none_existing(self, mock_today):
        mock_today.return_value = pytz.utc.localize(
            datetime.datetime(2014, 4, 5))
        period = FlowEventFactory(user=self.period.user,
                                  timestamp=TIMEZONE.localize(
                                      datetime.datetime(2014, 2, 27)))

        period_models.update_statistics(period_models.FlowEvent, period)

        stats = period_models.Statistics.objects.get(user=self.period.user)
        self.assertEqual(27, stats.average_cycle_length)
        self.assertEqual(27, stats.all_time_average_cycle_length)
        self.assertEqual(37, stats.current_cycle_length)
        expected_events = [{
            'timestamp': datetime.date(2014, 3, 12),
            'type': 'projected ovulation'
        }, {
            'timestamp': datetime.date(2014, 3, 26),
            'type': 'projected period'
        }, {
            'timestamp': datetime.date(2014, 4, 8),
            'type': 'projected ovulation'
        }, {
            'timestamp': datetime.date(2014, 4, 22),
            'type': 'projected period'
        }, {
            'timestamp': datetime.date(2014, 5, 5),
            'type': 'projected ovulation'
        }, {
            'timestamp': datetime.date(2014, 5, 19),
            'type': 'projected period'
        }]
        self.assertEqual(expected_events, stats.predicted_events)
예제 #6
0
    def test_with_average(self):
        FlowEventFactory(user=self.period.user,
                         timestamp=TIMEZONE.localize(
                             datetime.datetime(2014, 2, 15)))
        FlowEventFactory(user=self.period.user,
                         timestamp=TIMEZONE.localize(
                             datetime.datetime(2014, 3, 15)))
        FlowEventFactory(user=self.period.user,
                         timestamp=TIMEZONE.localize(
                             datetime.datetime(2014, 4, 10)))

        stats = period_models.Statistics.objects.filter(
            user=self.period.user).first()

        self.assertEqual(u'Jessamyn (', ('%s' % stats)[:10])
        self.assertEqual(23, stats.average_cycle_length)
        self.assertEqual(15, stats.cycle_length_minimum)
        self.assertEqual(28, stats.cycle_length_maximum)
        self.assertEqual(23, stats.cycle_length_mean)
        self.assertEqual(26, stats.cycle_length_median)
        self.assertEqual(None, stats.cycle_length_mode)
        self.assertEqual(7.0, stats.cycle_length_standard_deviation)
        expected_events = [{
            'timestamp': datetime.date(2014, 4, 19),
            'type': 'projected ovulation'
        }, {
            'timestamp': datetime.date(2014, 5, 3),
            'type': 'projected period'
        }, {
            'timestamp': datetime.date(2014, 5, 12),
            'type': 'projected ovulation'
        }, {
            'timestamp': datetime.date(2014, 5, 26),
            'type': 'projected period'
        }, {
            'timestamp': datetime.date(2014, 6, 4),
            'type': 'projected ovulation'
        }, {
            'timestamp': datetime.date(2014, 6, 18),
            'type': 'projected period'
        }]
        self.assertEqual(expected_events, stats.predicted_events)
예제 #7
0
 def setUp(self):
     self.user = UserFactory()
     self.period = FlowEventFactory()
예제 #8
0
 def setUp(self):
     self.period = FlowEventFactory()
예제 #9
0
 def setUp(self):
     super(TestFlowEventViews, self).setUp()
     self.url_path = reverse('flow_event_create')
     self.period = FlowEventFactory(user=self.user)
예제 #10
0
 def setUp(self):
     FlowEventFactory()
     self.serializer = FlowEventSerializer(
         instance=period_models.FlowEvent.objects.first())
 def setUp(self):
     self.command = email_active_users.Command()
     flow_event = FlowEventFactory()
     self.user = flow_event.user
     FlowEventFactory(user=self.user,
                      timestamp=TIMEZONE.localize(datetime.datetime(2014, 2, 28)))