def test_invalid_date(self, mocked_now_date, mocked_waffle_switch): mocked_waffle_switch.return_value = False UserFactory.create(userprofile__is_rotm_nominee=True) UserFactory.create(userprofile__is_rotm_nominee=True) UserFactory.create(username='******') mocked_now_date.return_value = datetime(now().year, now().month, 5) poll_name = ('Rep of the month for {0}'.format( number2month(now().month))) create_rotm_poll() poll = Poll.objects.filter(name=poll_name) ok_(not poll.exists())
def test_base(self, mocked_now_date): nominee_1 = UserFactory.create(userprofile__is_rotm_nominee=True) nominee_2 = UserFactory.create(userprofile__is_rotm_nominee=True) UserFactory.create(username='******') mocked_now_date.return_value = datetime(now().year, now().month, 11) poll_name = ('Rep of the month for {0}'.format( number2month(now().month))) create_rotm_poll() poll = Poll.objects.filter(name=poll_name) range_poll = RangePoll.objects.get(poll=poll) range_poll_choices = RangePollChoice.objects.filter( range_poll=range_poll) ok_(poll.exists()) eq_(poll.count(), 1) eq_(set([choice.nominee for choice in range_poll_choices]), set([nominee_1, nominee_2]))
def test_poll_already_exists(self, mocked_now_date, mocked_waffle_switch): mocked_waffle_switch.return_value = False UserFactory.create(userprofile__is_rotm_nominee=True) UserFactory.create(userprofile__is_rotm_nominee=True) UserFactory.create(username='******') # Nomination ends on the 10th of each month mocked_now_date.return_value = datetime(now().year, now().month, 10) poll_start = datetime(now().year, now().month, 1) poll_end = poll_start + timedelta(days=14) poll_name = ('Rep of the month for {0}'.format( number2month(now().month))) mentor_group = Group.objects.get(name='Mentor') poll = PollFactory.create(start=poll_start, end=poll_end, valid_groups=mentor_group, name=poll_name) create_rotm_poll() rotm_polls = Poll.objects.filter(name=poll_name) ok_(rotm_polls.exists()) eq_(rotm_polls.count(), 1) eq_(rotm_polls[0].pk, poll.pk)