Exemple #1
0
 def test_rounds_overlaping(self):
     """Test Rounds that overlap"""
     # create valid PhaseRound
     data = {
         'name': 'Round A',
         'phase': self.phase.id,
         'start_date': self.phase.start_date,
         'end_date': self.half_date,
         }
     form = PhaseRoundAdminForm(data)
     self.assertTrue(form.is_valid())
     round_a = form.save()
     assert round_a.id, "PhaseRound wasn't created"
     self.assertEqual(PhaseRound.objects.all().count(), 1)
     # create overlapping phase round
     # overlaping dates
     dates =[
         # wraps the date
         (self.start_date - self.delta, self.half_date + self.delta),
         # is contained in the date
         (self.start_date + self.delta, self.half_date - self.delta),
         # overlaps on the start
         (self.start_date + self.delta, self.end_date),
         # overlaps on the end
         (self.half_date - self.delta, self.end_date),
         ]
     for start, end in dates:
         data = {
             'name': 'Round',
             'phase': self.phase.id,
             'start_date': start,
             'end_date': end,
             }
         form = PhaseRoundAdminForm(data)
         self.assertFalse(form.is_valid())
     self.assertEqual(Phase.objects.all().count(), 1)
     # add new Round with a valid Phase
     data = {
         'name': 'Round B',
         'phase': self.phase.id,
         'start_date': self.half_date + relativedelta(seconds=1),
         'end_date': self.end_date,
         }
     form = PhaseRoundAdminForm(data)
     self.assertTrue(form.is_valid())
     round_b = form.save()
     assert round_b.id, "PhaseRound wasn't created"
     self.assertEqual(PhaseRound.objects.all().count(), 2)
Exemple #2
0
 def test_rounds_overlaping(self):
     """Test Rounds that overlap"""
     # create valid PhaseRound
     data = {
         'name': 'Round A',
         'phase': self.phase.id,
         'start_date': self.phase.start_date,
         'end_date': self.half_date,
     }
     form = PhaseRoundAdminForm(data)
     self.assertTrue(form.is_valid())
     round_a = form.save()
     assert round_a.id, "PhaseRound wasn't created"
     self.assertEqual(PhaseRound.objects.all().count(), 1)
     # create overlapping phase round
     # overlaping dates
     dates = [
         # wraps the date
         (self.start_date - self.delta, self.half_date + self.delta),
         # is contained in the date
         (self.start_date + self.delta, self.half_date - self.delta),
         # overlaps on the start
         (self.start_date + self.delta, self.end_date),
         # overlaps on the end
         (self.half_date - self.delta, self.end_date),
     ]
     for start, end in dates:
         data = {
             'name': 'Round',
             'phase': self.phase.id,
             'start_date': start,
             'end_date': end,
         }
         form = PhaseRoundAdminForm(data)
         self.assertFalse(form.is_valid())
     self.assertEqual(Phase.objects.all().count(), 1)
     # add new Round with a valid Phase
     data = {
         'name': 'Round B',
         'phase': self.phase.id,
         'start_date': self.half_date + relativedelta(seconds=1),
         'end_date': self.end_date,
     }
     form = PhaseRoundAdminForm(data)
     self.assertTrue(form.is_valid())
     round_b = form.save()
     assert round_b.id, "PhaseRound wasn't created"
     self.assertEqual(PhaseRound.objects.all().count(), 2)
Exemple #3
0
 def test_round_outside_phase(self):
     """Round dates outside the phase valid dates"""
     data = {
         'name': 'Round A',
         'phase': self.phase.id,
         'start_date': self.phase.start_date - self.delta,
         'end_date': self.phase.end_date,
         }
     form = PhaseRoundAdminForm(data)
     self.assertFalse(form.is_valid())
Exemple #4
0
 def test_round_outside_phase(self):
     """Round dates outside the phase valid dates"""
     data = {
         'name': 'Round A',
         'phase': self.phase.id,
         'start_date': self.phase.start_date - self.delta,
         'end_date': self.phase.end_date,
     }
     form = PhaseRoundAdminForm(data)
     self.assertFalse(form.is_valid())
Exemple #5
0
 def test_valid_phase(self):
     """Create a valid phase submission from the Phase details"""
     data = {
         'name': 'Round A',
         'phase': self.phase.id,
         'start_date': self.start_date,
         'end_date': self.end_date,
         }
     form = PhaseRoundAdminForm(data)
     self.assertTrue(form.is_valid())
     instance = form.save()
     assert instance.id, "PhaseRound wasn't created"
     self.assertEqual(Phase.objects.all().count(), 1)
Exemple #6
0
 def test_valid_phase(self):
     """Create a valid phase submission from the Phase details"""
     data = {
         'name': 'Round A',
         'phase': self.phase.id,
         'start_date': self.start_date,
         'end_date': self.end_date,
     }
     form = PhaseRoundAdminForm(data)
     self.assertTrue(form.is_valid())
     instance = form.save()
     assert instance.id, "PhaseRound wasn't created"
     self.assertEqual(Phase.objects.all().count(), 1)