def setUp(self): self.client = Client() self.milestone_id = 1 self.issue_id = 1 self.non_existed_milestone_id = 5 self.milestone_log_url = reverse('events:milestone_log', kwargs={'pk': self.milestone_id}) self.issue_log_url = reverse('events:issue_log', kwargs={'pk': self.issue_id}) self.all_comments_url = reverse('events:comment_list') self.comment_by_issue_url = reverse('events:comment_list_for_issue', kwargs={'issue_id': self.issue_id}) self.new_comment_url = reverse('events:comment_new') self.username = '******' self.password = '******' self.invalid_password = '******' self.auth_user = create_auth_user() self.user = create_user(self.auth_user) self.project = create_project(self.user) self.milestone = create_milestone(self.project) self.issue = create_issue(self.project, self.milestone) create_issue_event(self.issue_id, self.auth_user) self.client.login(username=self.username, password=self.password)
def test_issue_update_changing_event_created(self): issue = Issue.objects.get(pk=self.issue_id) # SET TO OPEN BY DEFAULT issue_state_before_update = issue.state issue_events_before = ChangingIssue.objects.filter( issues__id=self.issue_id).order_by('-time') issue_events_before_latest = issue_events_before[0] issue_events_before_len = issue_events_before.count() # UPDATE issue_state_after_update = 'CLOSED' issue.state = issue_state_after_update issue.save() create_issue_event(self.issue_id, self.auth_user) issue_events_after = ChangingIssue.objects.filter( issues__pk=self.issue_id).order_by('-time') issue_events_after_len = issue_events_after.count() issue_events_after_latest = issue_events_after[0] # new event added self.assertEqual(issue_events_before_len + 1, issue_events_after_len) # old value self.assertEqual(issue_events_before_latest.new_state, issue_state_before_update) # new event value set correct self.assertEqual(issue_events_after_latest.new_state, issue_state_after_update)
def setUp(self): self.auth_user = create_auth_user() self.user = create_user(self.auth_user) self.project = create_project(self.user) self.milestone = create_milestone(self.project) self.issue = create_issue(self.project, self.milestone) self.issue_id = self.issue.id create_issue_event(self.issue_id, self.auth_user)
def form_valid(self, form): response = super().form_valid(form) auth_user = self.request.user create_issue_event(self.object.pk, auth_user) metrics.issue_updated.inc() return response