コード例 #1
0
 def test_users(self):
     cohort = self.mox.CreateMockAnything()
     cohort.users = User.objects.all()
     self.mox.ReplayAll()
     self.assertEqual(list(Period(cohort, start_day=1, end_day=30).users),
                      [self.user])
     self.assertEqual(list(Period(cohort, start_day=30, end_day=60).users),
                      [])
     self.mox.VerifyAll()
コード例 #2
0
 def test_periods(self):
     cohort = self.mox.CreateMockAnything()
     cohort.users = User.objects.all()
     self.mox.ReplayAll()
     periods = list(Period.periods(cohort, [60, 30, 90]))
     for period in periods:
         self.assertEqual(period.cohort, cohort)
     self.assertEqual(periods[0].start_day, 1)
     self.assertEqual(periods[0].end_day, 30)
     self.assertEqual(periods[1].start_day, 30)
     self.assertEqual(periods[1].end_day, 60)
     self.assertEqual(periods[2].start_day, 60)
     self.assertEqual(periods[2].end_day, 90)
     self.mox.VerifyAll()
コード例 #3
0
 def test_periods(self):
     cohort = self.mox.CreateMockAnything()
     cohort.users = User.objects.all()
     self.mox.ReplayAll()
     periods = list(Period.periods(cohort, [60, 30, 90]))
     for period in periods:
         self.assertEqual(period.cohort, cohort)
     self.assertEqual(periods[0].start_day, 1)
     self.assertEqual(periods[0].end_day, 30)
     self.assertEqual(periods[1].start_day, 30)
     self.assertEqual(periods[1].end_day, 60)
     self.assertEqual(periods[2].start_day, 60)
     self.assertEqual(periods[2].end_day, 90)
     self.mox.VerifyAll()
コード例 #4
0
 def test_length(self):
     period = Period(cohort=None, start_day=1, end_day=30)
     self.assertEqual(period.length(), 29)
コード例 #5
0
 def test_length(self):
     period = Period(cohort=None, start_day=1, end_day=30)
     self.assertEqual(period.length(), 29)