def test_new_tickets(self): call_command('check_notifications') new_tickets_count = random.randint(1, 10) for i in range(new_tickets_count): self._generate_ticket(MILESTONE_09, self.get_ticket_number()) mailing_info = get_mailing_info() milestone_09_users = [user for user in self.users if user in get_user_milestones(user, only_notification=True)] for user in milestone_09_users: self.assertEqual(len(mailing_info[user.username].get(NEW_TICKETS)), new_tickets_count)
def __init__(self, *args, **kwargs): user = kwargs.pop('user', None) super(ReportForm, self).__init__(*args,**kwargs) if user: self.fields['component'].choices = list([EMPTY_CHOICE]) + [(component, component) for component in components_for_user(user)] self.fields['milestone'].choices = list([EMPTY_CHOICE]) + [(milestone, milestone) for milestone in get_user_milestones(user)] current_milestone = models.ProjectMilestone.objects.filter(is_current=True).first() self.fields['milestone'].initial = current_milestone.milestone if current_milestone else False