def test_current_release_creation(self): """Test the current release mechanics""" release = create_release('Release', True, self.ideation) self.assertEqual(release, Release.objects.get_current()) self.assertEqual(Release.objects.filter(is_current=True).count(), 1) # add an extra current release new_release = create_release('New release', True, self.development) self.assertEqual(new_release, Release.objects.get_current()) self.assertEqual(Release.objects.filter(is_current=True).count(), 1)
def test_timeslot_releases(self): """Test the available ``TimeSlots`` for a given ``Release``""" release_a = create_release('Release A', True, self.ideation) for i in range(2): create_timeslot(release_a) self.assertEqual(TimeSlot.available.all().count(), 2) release_b = create_release('Release B', True, self.ideation) self.assertEqual(TimeSlot.available.all().count(), 0) for i in range(2): create_timeslot(release_b) self.assertEqual(TimeSlot.available.all().count(), 2) self.assertEqual(TimeSlot.objects.all().count(), 4)
def test_upcoming_timeslots(self): release_a = create_release('Release A', True, self.ideation) for i in range(2): create_timeslot(release_a) self.assertEqual(TimeSlot.objects.all().count(), 2) self.assertEqual(TimeSlot.objects.upcoming().count(), 0) TimeSlot.objects.all().update(is_booked=True) self.assertEqual(TimeSlot.objects.upcoming().count(), 2)
def test_new_release_same_phase(self): release = create_release('Release B', True, self.ideation) self.client.login(username='******', password='******') response = self.client.get(self.listing_url) self.assertEqual(response.context['page'].paginator.count, 0) self.generate_timeslots(2, self.ideation, release=release) response = self.client.get(self.listing_url) self.assertEqual(response.context['page'].paginator.count, 2) self.assertEqual(TimeSlot.objects.all().count(), 4)
def setUp(self): self.initial_data = setup_ideation_phase(**setup_ignite_challenge()) self.ideation = self.initial_data['ideation_phase'] self.development = self.initial_data['dev_phase'] super(WebcastTest, self).setUp() self.submission_list = self.generate_submissions(2, self.ideation, user=self.profile, are_winners=True) self.release = create_release('Release', True, self.ideation)
def test_create_timeslot(self): """Create a ``TimeSlot`` with the less possible data""" release = create_release('Release', True, self.ideation) data = { 'start_date': datetime.utcnow(), 'end_date': datetime.utcnow() + relativedelta(hours=1), 'release': release, } timeslot = TimeSlot.objects.create(**data) assert timeslot.id, "TimeSlot not created"
def generate_timeslots(self, total, phase, release=None): """Create a number of ``TimeSlots`` with an active ``Release``""" release = release if release else create_release( 'Release', True, phase) return [create_timeslot(release) for i in range(total)]
def test_new_release_different_phase(self): create_release('Release B', True, self.development) self.client.login(username='******', password='******') response = self.client.get(self.listing_url) self.assertEqual(response.status_code, 404) self.assertEqual(TimeSlot.objects.all().count(), 2)
def generate_timeslots(self, total, phase, release=None): """Create a number of ``TimeSlots`` with an active ``Release``""" release = release if release else create_release('Release', True, phase) return [create_timeslot(release) for i in range(total)]